mysql, dump, database restore

后端 未结 3 383
终归单人心
终归单人心 2021-02-02 10:53

I have dumped my database with the following command:

mysqldump -uuser -ppassword db_name > file

then I completely removed my database:

相关标签:
3条回答
  • 2021-02-02 11:05

    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 讨论(0)
  • 2021-02-02 11:06

    I like to do the following to restore.

    mysql -uuser -ppassword
    create database db;
    use db;
    source dump.sql;
    
    0 讨论(0)
  • 2021-02-02 11:13

    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.

    0 讨论(0)
提交回复
热议问题