How can I import a database with MySQL from terminal?

后端 未结 18 1379
盖世英雄少女心
盖世英雄少女心 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:15

    If you are using sakila-db from mysql website, It's very easy on the Linux platform just follow the below-mentioned steps, After downloading the zip file of sakila-db, extract it. Now you will have two files, one is sakila-schema.sql and the other one is sakila-data.sql.


    1. Open terminal
    2. Enter command mysql -u root -p < sakila-schema.sql
    3. Enter command mysql -u root -p < sakila-data.sql
    4. Now enter command mysql -u root -p and enter your password, now you have entered into mysql system with default database.
    5. To use sakila database, use this command use sakila;
    6. To see tables in sakila-db, use show tables command

    Please take care that extracted files are present in home directory.

提交回复
热议问题