How to import a single table in to mysql database using command line

前端 未结 18 1928
你的背包
你的背包 2020-12-22 15:25

I had successfully imported a database using command line, but now my pain area is how to import a single table with its data to the existing database using command line.

18条回答
  •  旧时难觅i
    2020-12-22 15:58

    First of all, login to your database and check whether the database table which you want to import is not available on your database.

    If it is available, delete the table using the command. Else it will throw an error while importing the table.

    DROP TABLE Table_Name;
    

    Then, move to the folder in which you have the .sql file to import and run the following command from your terminal

    mysql -u username -p  databasename  < yourtable.sql
    

    The terminal will ask you to enter the password. Enter it and check the database.

提交回复
热议问题