MySQL command line Export Database: 1, enter the bin folder under the MySQL Directory: the directory from cdMySQL to the bin folder, as shown in the command line I entered: cdC: programFilesMySQLMySQLServer4.1bin (or directly add the directory to the windows environment variable path) 2. Export the database: mysqldump-u username-p Database
MySQL command line to export the database: 1, enter the bin folder under the MySQL Directory: cd MySQL to the bin folder directory, such as the command line I entered: cd C: \ Program Files \ MySQL Server 4.1 \ bin (or directly add the directory to the windows environment variable path) 2. Export the database: mysqldump-u username-p Database
MySQL command line to export the database:
1. Go to the bin folder under the MySQL Directory: directory from cd MySQL to the bin folder
For example, if the command line I entered is cd C: \ Program Files \ MySQL Server 4.1 \ bin
(Or directly add the directory to the path of the windows environment variable)
2. Export Database: mysqldump-u username-p Database Name> exported file name
For example, the command line I entered is mysqldump-u root-p news> news. SQL (after entering the command, you will be asked to enter the MySQL password)
(If you export a single table, enter the table name after the database name)
3. The file news. SQL is automatically generated under the binfile.
Command Line import database:
1. The. SQL file to be imported is moved to the binfile, which is convenient.
2. Step 1 of the above-mentioned export
3. Enter MySQL: mysql-u username-p
For example, the command line I entered is mysql-u root-p (enter the same password for MySQL)
4. Create the database you want to create in MySQL-Front. An empty database is used, for example, create a target database named "news ".
5. Enter the mysql> use target database name.
For example, the command line I entered is mysql> use news;
6. Import file: the file name imported from mysql> source;
For example, the command line I entered is mysql> source news. SQL;
MySQL backup and restoration are completed using mysqldump, mysql, and source commands.
1. MySQL backup and restoration under Win32
1.1 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 database to file, for example, mysqldump-u root-p voice> voice. SQL, and then enter the password to start exporting.
1.2 restore
Enter the MySQL Command Line Client, enter the password, go to "mysql>", enter the Command "show databases;", Press enter to see what databases are there, and 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 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] # mysql-u root-p voice