Briefly describe the way the command line enters MySQL:
1.c:>mysql-h Hostname-u Username-p
Press ENTER to wait and then enter the password. Here hostname is the name of the server, such as the user name Localhost,username for MySQL, such as root.
After entering the command line, you can directly manipulate MySQL.
1. Export the entire database
Mysqldump-u user name-p database name > exported file name
The code is as follows |
Copy Code |
Mysqldump-u wcnc-p SMGP_APPS_WCNC > Wcnc.sql Mysqldump-u root-p aikersql> Aiker.sql |
2. Export a table
Mysqldump-u user name-P database name Table name > exported file name
The code is as follows |
Copy Code |
Mysqldump-u wcnc-p SMGP_APPS_WCNC users> wcnc_users.sql |
3. Export a database structure
The code is as follows |
Copy Code |
Mysqldump-u wcnc-p-d–add-drop-table SMGP_APPS_WCNC >d:wcnc_db.sql |
-D No data –add-drop-table add a drop table before each CREATE statement
4. Import Database
Common source Commands
Enter the MySQL database console,
such as Mysql-u root-p
Mysql>use Database
Then use the source command, followed by the script file (such as the. SQL used here)
Mysql>source D:wcnc_db.sql
To transfer text data to a database
1, the text data should conform to the format: The field data is separated by the TAB key, null value with N to replace.
Cases:
3 Rose Shenzhen II 1976-10-10
4 Mike Shenzhen one 1975-12-23
2, Data incoming command load infile "filename" into table name;
Note: You'd better copy the files to the Mysqlbin directory and use the using command to hit the library where the table resides.
Data export
There are several main methods for data export:
Use SELECT INTO outfile "filename" statement
Using the Mysqldump utility
Import using phpMyAdmin
For example:mysql> SELECT * from driver into outfile "a.txt";
Import
Similar to exports, there are two ways to import:
Use the load DATA INFILE "filename" command
Using the Mysqlimport utility
Import using phpMyAdmin
Using SQL files