MySQL command line export database

Source: Internet
Author: User
Tags import database mysql backup mysql command line

MySQL command line export database: 1, go to the Bin folder in the MySQL directory: cd MySQL to the Bin folder directory as I entered the command line: CD C:\Program files\mysql\mysql Server 4.1\bin ( or add the directory directly to the Windows environment variable path)

2, Export database: Mysqldump-u username-P database name > exported file name as I entered the command line: Mysqldump-u root-p News > News.sql (input will let you enter MySQL password) (if the export Single-Sheet words, enter the table name after the database name.

3. You will see the file News.sql automatically generated to the bin file under the command line Import database:

1, the. sql file to be imported into the bin file, such a path is more convenient 2, with the above exported 1th Step 3, enter the MYSQL:MYSQL-U user name-p as I entered the command line: mysql-u root-p (Input the same will let you enter the MySQL password) 4, in Mysql-front Create a new database you want to build, this is an empty database, such as a new target database named News 5, enter: Mysql>use target database name as I entered the command line: Mysql>use news; 6, import file: mysql>source import filename; As I entered the command line: Mysql>source news.sql;

The

MySQL backup and restore is done using the mysqldump, MySQL, and source commands. 1.win32 backup and restore under MySQL 1.1 Backup Start Menu | Run | cmd | Enter the Bin folder with the "CD \program Files\mysql\mysql Server 5.0\bin" command | Export the database to a file, such as Mysqldump-u root-p voice>, using "mysqldump -u user name-P databasename >exportfilename" Voice.sql, then enter the password to start the export.   1.2 restore into MySQL command line Client, enter the password, enter the "mysql>", enter the command "show databases;", enter to see what the database is; build the database you want to restore, enter the "Create Database voice; ", carriage return; switch to the newly created databases, type" use voice; ", enter; Import data, enter" source voice.sql; ", carriage return, start import," mysql> "again, and the restore succeeds without prompting the error.   2.Linux MySQL backup and restore 2.1 backup [[[Email protected] ~]# cd/var/lib/mysql (go to MySQL library directory, adjust the directory according to your MySQL installation) [[ Email protected] mysql]# mysqldump-u root-p voice>voice.sql, enter the password. 2.2 Restore method One: [[email protected] ~]# mysql-u root-p return, enter the password, enter the MySQL console "mysql>", with 1.2 restore. Law two: [[email protected] ~]# cd/var/lib/mysql (go to MySQL library directory, adjust the directory according to your MySQL installation) [[email protected] mysql]# Mysql-u root-p voice<voice.sql, enter the password.

This article from Csdn Blog, reproduced please indicate the source: http://blog.csdn.net/quietprofound/archive/2008/09/19/2947197.aspx

MySQL command line export database

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.