Methods for importing and exporting. sql files from the MySQL import command line mode

Source: Internet
Author: User
Tags mysql import

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.