How can I import a database with MySQL from terminal?

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

    Below command is working on ubuntu 16.04, I am not sure it is working or not other Linux platforms.

    Export SQL file:

    $ mysqldump -u [user_name] -p [database_name] < [database_name.sql]  
    

    Example : mysqldump -u root -p max_development > max_development.sql

    Import SQL file:

    $ mysqldump -u [user_name] -p [database_name] > [file_name.sql]
    
    Example: mysqldump -u root -p max_production < max_development.sql
    

    Note SQL file should exist same directory

提交回复
热议问题