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:




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


Create User From MYSQL Command Prompt

mysql> CREATE USER 'username'@'host' IDENTIFIED BY 'password';

Show Every User In MYSQL Database In One Line

mysql> select user,host,account_locked from mysql.user;

Change User Password In MySQL Database In One Line

mysql> alter user user@localhost identified by 'NewPassword';