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

后端 未结 30 2641
不知归路
不知归路 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:36

    Providing credentials on the command line is not a good idea. The above answers are great, but neglect to mention

    mysql --defaults-extra-file=etc/myhost.cnf database_name < file.sql
    

    Where etc/myhost.cnf is a file that contains host, user, password, and you avoid exposing the password on the command line. Here is a sample,

    [client]
    host=hostname.domainname
    user=dbusername
    password=dbpassword
    

提交回复
热议问题