MySQL command line export database _ MySQL

Source: Internet
Author: User
Tags localhost mysql import database
MySQL command line export database bitsCN.com
MySQL command line export database MySQL command line export Database: 1, enter the bin folder under the MySQL Directory: cd MySQL to the bin folder directory, such as the command line I entered: cd C: /Program Files/MySQL Server 4.1/bin (or directly add the directory to the windows environment variable path) 2, export the database: mysqldump-u username-p database name> The exported file name is shown in the command line: mysqldump-u root-p news> news. SQL (after you enter the password for entering MySQL) (if you export a single table, enter the table name after the database name) 3. the file news is displayed. SQL automatically generated to binfile command line import database: 1, to be imported. move the SQL file to the binfile. This path is more convenient. 2. go to MySQL: mysql-u username-p, as shown in the following command line: mysql-u root-p (after entering the same password, you will be asked to enter the MySQL password) 4. create the database you want to create in MySQL-Front. in this case, the database is empty, for example, create a target database named "news ".
5. enter the mysql> use target database name, for example, mysql> use news; 6. Import File: mysql> source import file name, for example, the command line I entered: mysql> source news. SQL; MySQL backup and restoration are completed using mysqldump, mysql, and source commands. 1. mySQL backup and restoration 1.1 Backup start menu under Win32 | run | cmd | use the "cd/Program Files/MySQL Server 5.0/bin" command to enter the bin folder | use "mysqldump "-u username-p databasename> exportfilename "to export the database to a file, for example, mysqldump-u root-p voice> voice. SQL, and then enter the password to start exporting. 1.2 restore to MySQL Command Line Client, enter the password, go to "mysql>", enter the Command "show databases;", press enter to see what database; create the database you want to restore, enter "create database voice;", press enter; switch to the database you just created, enter "use voice;", press enter; import data, and enter "source voice. SQL; ", press enter to start importing, and" mysql> "is displayed again. if no error is returned, the restoration is successful. 2. MySQL backup and restoration in Linux [root @ localhost ~] # Cd/var/lib/mysql (go to the MySQL database directory and adjust the directory based on your MySQL installation) [root @ localhost mysql] # mysqldump-u root-p voice> voice. SQL, enter the password.
2.2 Reduction Method 1: [root @ localhost ~] # Mysql-u root-p Press enter and enter the password to go to the MySQL console "mysql>", which is restored in the same way as 1.2. Method 2: [root @ localhost ~] # Cd/var/lib/mysql (enter the MySQL database directory and adjust the directory according to your MySQL installation) [root @ localhost mysql] # mysql-u root-p voice

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.