Home  >  Q&A  >  body text

How to import a MySQL database from the terminal?

How to import mysql database from terminal?

I can't find the exact syntax.

P粉990568283P粉990568283375 days ago567

reply all(2)I'll reply

  • P粉633075725

    P粉6330757252023-10-11 10:06:07

    Preferred method for Windows:

    1. Open the console and start interactive MySQL mode

    2. use;

    3. source

    reply
    0
  • P粉936568533

    P粉9365685332023-10-11 00:30:32

    Assuming you are using a Linux or Windows console:

    Prompt for password:

    mysql -u <username> -p <databasename> < <filename.sql>

    Enter password directly (unsafe):

    mysql -u <username> -p<PlainPassword> <databasename> < <filename.sql>

    Example:

    mysql -u root -p wp_users < wp_users.sql
    
    mysql -u root -pPassword123 wp_users < wp_users.sql

    See also:

    4.5.1.5. Execute SQL statements from text files


    Note: If you are using Windows, you must cd (change directory) to the MySQL/bin directory within CMD before executing the command.

    reply
    0
  • Cancelreply