The following articles mainly describe how to implement MySQL backup and restoration under Win32. The following articles describe the actual operation solution. If you have mastered this technology, it will be of great help in future studies or work.
1. MySQL backup and restoration under Win32
1.1 MySQL backup Start Menu | run | cmd | use the "cd \ Program Files \ MySQL Server 5.0 \ bin" command to enter the bin folder | use "mysqldump-u username-p databasename> exportfilename "to export the database to a file, for example, mysqldump-u root-p voice> voice. SQL, and then enter the password to start exporting.
1.2 restore to MySQL Command Line Client, enter the password, go to "mysql>", enter the Command "show databases;", Press enter to see what database; create the database you want to restore, enter "create database voice;", Press ENTER; switch to the database you just created, enter "use voice;", Press ENTER; import data, and enter "source voice. SQL; ", Press enter to start importing, and" mysql> "is displayed again. If no error is returned, the restoration is successful. 2. MySQL backup and restoration in Linux
2.1 MySQL backup [root @ localhost ~] # Cd/var/lib/mysql (go to the MySQL database directory and adjust the directory based on your MySQL installation) [root @ localhost mysql] # mysqldump-u root-p voice> voice. SQL, enter the password.
2.2 restore
Method 1: [root @ localhost ~] # Mysql-u root-p press enter and enter the password to go To the MySQL console "mysql>", which is restored in the same way as 1.2.
Method 2: [root @ localhost ~] # Cd/var/lib/mysql (go to the MySQL database directory and adjust the directory based on your MySQL installation) [root @ localhost mysql] # installation configuration of mysql-u root-p voice Green Edition
I downloaded MySQL 5.1.
Download the free installation package (mysql-noinstall-5.1.45-win32.zip)
Decompress the compressed file to E: \ mysql-5.1.39-win32
1. Add E: \ mysql-5.1.39-win32 \ bin in the path of the system environment variable Note: This is my MySQL installation path)
2. Edit the mysql backup run configuration file my. ini. If not, copy the my-medium.ini and name it my. ini
Copy one copy to E: \ mysql-5.1.39-win32 and C: \ WINDOWS respectively
Edit the my. ini file.
[Mysqld]
# Set the installation directory of mysql
Basedir = E:/mysql-5.1.39-win32/
# Set the data storage directory of the mysql database, which must be data or \ xxx \ data
Datadir = E:/mysql-5.1.39-win32/data
# Set the character set of the mysql server
Default-character-set = utf8
[Client]
# Set the character set of the mysql client
Default-character-set = gbk
Note: The configuration in the split line is optional. You can set it when creating a database.
3. Install the mysql Service
Enter the directory E: \ myserver \ MS-DOS \ bin from the mysql-5.0.37-win32 window and run the following command:
Mysqld -- install mysql5 -- defaults-file = C: \ WINDOWS \ my. ini
Mysql5 is only the name of the service. You can set it by yourself. For example, change it to xiaomai.
That is, mysqld -- install xiaomai -- defaults-file = C: \ WINDOWS \ my. ini
4. Start the mysql database
In the above command window, enter the command: net start mysql5
In this way, the mysql service is started.
5. Stop the service
Execute net stop mysql5.
6. After the installation is completed in the preceding five steps, the default root user password of MySQL is blank.
You can set the root password:
Win + R-> Enter cmd-> open the windows command console and locate the file directory at will, as shown below:
- E:\erlangPro\mysqlTest\src>mysql -u root -p
- Enter password:
- Welcome to the MySQL monitor. Commands end with ; or \g.
- Your MySQL connection id is 8
- Server version: 5.1.39-community MySQL Community Server (GPL)
- Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
- mysql> use mysql
- Database changed
- mysql> update user set passwordpassword=password('admin') where user='root';
- Query OK, 2 rows affected (0.03 sec)
- Rows matched: 2 Changed: 2 Warnings: 0
- mysql>
Log out of MySQL and restart the MySQL service.
The above content is an introduction to MySQL backup and restoration under Win32. I hope you will have some gains.