Restore a MySQL database using command lines

Source: Internet
Author: User

 

Today, when I recovered a database, I was really depressed. I used a graphical interface (MySQL administraotr), and the backup file was about 8 Mb. It was nearly 40 minutes after recovery, it is as slow as a cow (my machine configures Core 2 + 2 GB memory ). At last, it was shown that the database was successfully restored, but the recovered database was still not found several times.

 

I 'd like to try it through the command line. The result is ...... In less than two seconds, I thought it would be okay, but the miracle occurred. I refreshed the list and the database actually showed up. It was amazing.

 

 

 

The following is a command line. I can't remember it. It will be easy to check it after it is put here.

 

# Cd/usr/local/MySQL/bin/

 

// Create a database

# Mysqladmin-uroot-ppass create database_name

 

// Restore the database

# Mysql-uroot-ppass database_name <db_backup. SQL

 

// Add a user to the database and set the access permission

# Mysql-uroot-ppass

Mysql> grant all privileges on database_name. * To 'user' @ 'localhost' identified by "pass ";

 

 

 

 

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.