How do I import an SQL file using the command line in MySQL?

后端 未结 30 2248
不知归路
不知归路 2020-11-22 06:48

I have a .sql file with an export from phpMyAdmin. I want to import it into a different server using the command line.

I have a Windows Ser

30条回答
  •  礼貌的吻别
    2020-11-22 07:18

    To dump a database into an SQL file use the following command.

    mysqldump -u username -p database_name > database_name.sql
    

    To import an SQL file into a database (make sure you are in the same directory as the SQL file or supply the full path to the file), do:

    mysql -u username -p database_name < database_name.sql
    

提交回复
热议问题