Restore MYSQL Dump File with Command Line

前端 未结 9 1464
长情又很酷
长情又很酷 2021-02-04 02:57

I have file.sql, and I want to restore it. I found this command:

mysql -u username -p database_name < file.sql

Where should I put \'file.sql\' in

9条回答
  •  长情又很酷
    2021-02-04 03:32

    Type the following command to import sql data file:

    $ mysql -u username -p -h localhost DATA-BASE-NAME < data.sql
    

    In this example, import 'data.sql' file into 'blog' database using vivek as username:

    $ mysql -u sat -p -h localhost blog < data.sql
    

    If you have a dedicated database server, replace localhost hostname with with actual server name or IP address as follows:

    $ mysql -u username -p -h 202.54.1.10 databasename < data.sql
    

    OR use hostname such as mysql.cyberciti.biz

    $ mysql -u username -p -h mysql.cyberciti.biz database-name < data.sql
    

    If you do not know the database name or database name is included in sql dump you can try out something as follows:

    $ mysql -u username -p -h 202.54.1.10 < data.sql
    

    Refer: http://dev.mysql.com/doc/refman/5.6/en/mysqldump.html

提交回复
热议问题