MySQL In Commandline

To log into MySQL monitor or client

Open a terminal and type:

mysql -u username -p

Change username to your actual username or root. After hitting enter, you should be prompted to give your password.

To List Your MySQL Databases

Enter at mysql prompt:

mysql> SHOW DATABASES;

also,

mysql> SHOW SCHEMA;

Search Through List Of Databases

Search through a long list of databases by typing:

mysql> SHOW DATABASE text_string;

Use your search query in place of “text_string”

Show Every MySQL Database In One Line

$ mysql -u username -p password -e "show databases;"
  • mysql – This launches the MySQL shell
  • –u username – Replace username with the actual username for the database
  • –p password – Replace password with the actual password for the user
  • e – Executes the following statement, then exits MySQL shell
  • “show databases;” – Specifies the command to execute

Source