开发者

mysql, dump, database restore

开发者 https://www.devze.com 2023-02-10 13:37 出处:网络
I have dumped my database with the following command: mysqldump -uuser -ppassword db_name > file then I completely removed my database:

I have dumped my database with the following command:

mysqldump -uuser -ppassword db_name > file

then I completely removed my database:

drop database db_name;

then I created a new database:

create database db_name;

and then I tried to restore the db with the following command:

mysqldump -uuser -ppassword db_name < file

The problem is that dump does not create tables and loads data in them and so the database remains empty however it does show a message like dump completed "date time开发者_C百科"

What could be the reason for this?


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
0

精彩评论

暂无评论...
验证码 换一张
取 消