Basic commands of MySQL command line


Here are few commands of MySQL command line

Connect to MySQL

You will prompt to enter a password if it’s localhost and password is not set for root user and just hit enter.

To Show all Databases

Use or Select Database

Show Tables of Selected Database

Import SQL file to Database

Export Database to SQL file

If it’s an entire DB, then:

If it’s all DBs, then:

If it’s specific tables within a DB, then:

You can even go as far as auto-compressing the output using gzip (if your DB is very big):

If you want to do this remotely and you have the access to the server in question, then the following would work (presuming the MySQL server is on port 3306):

It should drop the .sql file in the folder you run the command-line from.

Leave a Reply