Skip to content
Fix Code Error

How can I import a database with MySQL from terminal?

March 13, 2021 by Code Error
Posted By: Anonymous

How can I import a database with mysql from terminal?

I cannot find the exact syntax.

Solution

Assuming you’re on a Linux or Windows console:

Prompt for password:

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

Enter password directly (not secure):

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. Executing SQL Statements from a Text File


Note: If you are on windows then you will have to cd (change directory) to your MySQL/bin directory inside the CMD before executing the command.

Answered By: anon

Related Articles

  • Simplest way to create Unix-like continuous pipeline in…
  • How to install the Raspberry Pi cross compiler on my Linux…
  • Reference — What does this symbol mean in PHP?
  • How to change the integrated terminal in visual studio code…
  • GLYPHICONS - bootstrap icon font hex value
  • How do you list volumes in docker containers?
  • Get operating system info
  • What are the undocumented features and limitations of the…
  • The definitive guide to form-based website authentication
  • how to log in to mysql and query the database from linux…

Disclaimer: This content is shared under creative common license cc-by-sa 3.0. It is generated from StackExchange Website Network.

Post navigation

Previous Post:

How to get first character of string?

Next Post:

How to check if the URL contains a given string?

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

  • Get code errors & solutions at akashmittal.com
© 2022 Fix Code Error