Today, a classmate asked me if I can transfer the database, I thought that should be a new table, but that efficiency is too low, and also need to import a lot of records in the table, trouble, so think of MySQL bin in two instructions, mysqldump and resource.
MySQL command line export database:
1. First we go through the command line to the MySQL installation directory of the bin directory, such as I entered the command behavior: CD c:program filesmysqlmysql Server 5.5bin
(If the Win7 system, and MySQL installed in the C disk directory, if the instructions above to deny access, it is the administrator's way to run the command prompt on the line)
2. Export database: Mysqldump-u user name-p database name > exported file name
As I entered the command line: mysqldump-u root-p ATM > Atm.sql (Input will allow you to enter the password into MySQL)
(If you export a single table, enter the table name after the database name)
3. After executing the above command, we can see the Atm.sql database file we just exported in the bin directory, which contains all the tables in the database and the records in the table.
MySQL command line Import Database:
1. First of all, we will import the. sql file into the database into the bin directory, which is more convenient.
2. Then we enter the MySQL Command line Client, enter the password, go to "mysql>", create a new database (Mysql>create DB test;)
3. Use the newly created database Mysql>use test;
4. import file: Mysql>source the imported filename; For example, I want to import the Atm.sql data file I just exported: Mysql>source atm.sql;
5. If there is no hint of error message, we can use show tables to see that the newly created test database has already imported the contents of the new ATM database.