Category: MySQL technology 2013-09-08 20:17 7350 people Read reviews (0) Favorite Report
command line mode MySQL import export. sql file method
Methods for importing and exporting. sql files from the MySQL import command line mode
One. mysql command-line mode settings:
Desktop, My Computer, properties, environment variables, new
Path= "; path\mysql\bin;" Where path is the installation path for MySQL.
Two. A simple introduction to the command line into the MySQL method:
1.c:\>mysql-h hostname-u username-p. C:\>mysql-h Localhost-u Root-p
Press ENTER, wait and enter the password. Here hostname is the name of the server, such as localhost,username as the MySQL username, such as root.
MySQL can be manipulated directly after entering the command line.
2. Simply introduce the MySQL command:
Mysql->create database dbname;//Creating databases
Mysql->create table tablename;//Creating tables
Mysql->show databases;//Displays database information, which databases are available.
Mysql->use dbname;//Select a database
Mysql->show tables;//display table information, which tables are available
Mysql->describe tablename;//Display information for the created table
Three. Export the database file from the database:
1. Export the database mydb to the E:\mysql\mydb.sql file:
Open Start-to-run input cmd enter command-line mode
C:\>mysqldump-h localhost-u root-p mydb >e:\mysql\mydb.sql
Then enter the password, wait for an export to succeed, you can check the target file for success.
2. Export the mytable in the database mydb to the E:\mysql\mytable.sql file:
C:\>mysqldump-h localhost-u root-p mydb mytable>e:\mysql\mytable.sql
3. Export the structure of the database mydb to the E:\mysql\mydb_stru.sql file:
C:\>mysqldump-h localhost-u root-p mydb--add-drop-table >e:\mysql\mydb_stru.sql
Four. Import data from an external file into the database:
Import the SQL statements from the file into the database from E:\mysql\mydb2.sql:
1. Go to MySQL from the command line and create database mydb2 with the command; mydb2.
2. Exit MySQL to enter the command exit, or quit;
3. Enter the following command in CMD:
C:\>mysql-h localhost-u root-p MYDB2 < E:\mysql\mydb2.sql
Then enter the password and it's OK.
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
Methods for importing and exporting. sql files from the MySQL import command line mode