command line source Import Database:
| The code is as follows |
Copy Code |
1, to move the imported. sql file to the bin file, this is a convenient path 2, the 1th step with the above export 3, enter mysql:mysql-u user name-P As I entered the command line: Mysql-u root-p (Enter the same will let you enter the Ysql password) 4, in the Mysql-front of the new database you want to build, at this time is an empty database, such as a new target named blog (mysql>create database blog;) 5, enter: Mysql>use Target database name As I entered the command line: Mysql>use blog; 6, import file: Mysql>source import of the file name; As I entered the command line: Mysql>source blog.sql; |
Other Import methods
First, MySQL import files or data or execute related SQL
Mysql-h host Address-u user name-P user Password
1. Document form. (Shell command line)
1
| The code is as follows |
Copy Code |
Mysql-u Root-p dbname < Filename.sql
|
2. Directly on the command line (Shell command line) executes a SQL
| The code is as follows |
Copy Code |
1 mysql-hhostname-uusername-p dbname-e ' select * from Tbname limit 1 ' The command line prompts you to enter the database password after execution. :) |
3. Take SQL as an input to MySQL (Shell command line)
| The code is as follows |
Copy Code |
1 echo ' select ID from dbname.tbname where id = 1; ' | Mysql-hhostname-ureadonly-preadonly dbname > Xxxx.sql |
command-line export database:
Export the Mysqldump tool that you want to use with MySQL, basic usage:
Shell> mysqldump [OPTIONS] database [tables]
If you do not give any tables, the entire database will be exported.
By executing mysqldump–help, you can get a list of the options supported by your mysqldump version.
1, into the MySQL directory under the Bin folder: cd MySQL to the Bin folder directory
As I entered the command line: CD F:program filesmysqlmysql Server 5.1bin (Bin folder for MySQL installation path)
2, Export database: Mysqldump-u user name-p database name > exported file name
As I entered the command line: Mysqldump-u root-p bolg> blog.sql (input will allow you to enter the password into MySQL)
Some common export data SQL statements
| The code is as follows |
Copy Code |
Mysqldump-u user name-p database name > exported file name Mysqldump-u wcnc-p SMGP_APPS_WCNC > Wcnc.sql |
2. Export a table
| The code is as follows |
Copy Code |
Mysqldump-u user name-P database name Table name > exported file name 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