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

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

    For importing multiple SQL files at one time, use this:

    # Unix-based solution
    for i in *.sql;do mysql -u root -pPassword DataBase < $i;done
    

    For simple importing:

    # Unix-based solution
    mysql -u root -pPassword DataBase < data.sql
    

    For WAMP:

    #mysqlVersion replace with your own version
    C:\wamp\bin\mysql\mysqlVersion\bin\mysql.exe -u root -pPassword DataBase < data.sql
    

    For XAMPP:

    C:\xampp\mysql\bin\mysql -u root -pPassword DataBase < data.sql
    

提交回复
热议问题