How can I import a database with MySQL from terminal?

后端 未结 18 1365
盖世英雄少女心
盖世英雄少女心 2020-11-27 09:14

How can I import a database with mysql from terminal?

I cannot find the exact syntax.

18条回答
  •  鱼传尺愫
    2020-11-27 09:37

    After struggling for sometime I found the information in https://tommcfarlin.com/importing-a-large-database/

    1. Connect to Mysql (let's use root for both username and password):

      mysql -uroot -proot
      
    2. Connect to the database (let's say it is called emptyDatabase (your should get a confirmation message):

      connect emptyDatabase
      

    3 Import the source code, lets say the file is called mySource.sql and it is in a folder called mySoureDb under the profile of a user called myUser:

    source /Users/myUser/mySourceDB/mySource.sql
    

提交回复
热议问题