Use mysql commands in CentOS to import and export. SQL data

Source: Internet
Author: User
Tags mysql commands

Use mysql commands in CentOS to import and export. SQL data

Recently, I was transferring data from the site. When I backed up the database, I found that the database was too large. I tried to upload phpmyadmin, but the success rate was not high. Many data tables were not completely restored, however, you can only use command lines to import data.

System Environment centos 6.5 64-bit, php + mysql Environment

Backup:

1. Enter the Bin directory under MySql, for example:

Cd/usr/local/mysql/bin2. basic backup. /mysqldump-uroot-proot mydb> backup. SQL Note: mydb is the name of the database to be backed up. the database username and password are both root; the backup result is saved in the current directory for backup. SQL

Restore:

1. log on to the system through SSH and log on to mysql DATA

# Mysql-u root-p # Note-p is to use the password to log on. Here, all logon attempts are mysql account and password # enter the password and enter it to log on to mysql>

2. Select a database

# Mysql> use database_name # Replace database_name with the database to be restored

3. Select the backup. SQL file to start importing.

# Mysql> source/root/backup-20140807. SQL # select the backup data corresponding path to complete

4. The data restoration result prompts that the process is complete.

If there is an exception in the restore result, follow the prompts to solve the problem.


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.