mysql, dump, database restore

女生的网名这么多〃 提交于 2019-12-03 01:31:00

mysqldump is for dumping the database. You've created a new empty database, and then dumped that empty database. Use mysql instead to reload your dump

mysqldump db > dump.sql
mysql drop/create
mysql db < dump.sql

would be the basic command sequence.

I like to do the following to restore.

mysql -uuser -ppassword
create database db;
use db;
source dump.sql;

I tried dump of my database with the following commands:

#mysqldump -u <username> -p <password> DB_name > <filename>.sql

Then login into the DB:

   #mysql -u <username> -p <password>
   >show databases;
   >drop database <DB_name>;

Then create a new database:

#create database <DB_name>;

DB_name is userdefined name we can have any name.

and then restore the DB with the following command:

#mysql -u <username> -p <password> DB_name < <filename>.sql
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!