The MySQL command line client

The MySQL command line client is a neat tool for every developer or sysadmin. It provides quick and simple access to your MySQL databases.

The tool usually comes with your MySQL installation. To start it, just run:


You shall see the client prompt:


To list all available databases, run:


To switch the database context you’re currently working with, execute:

 USE cloudbalkan_db

Where ‘cloudbalkan_db’ is the name of the database to connect to.

To show all tables in a database, you can use:


This is some very brief quick start on using the command line client.

The command line client supports authentication and remote connections. To use them you can add the following flags to the ‘mysql ‘ command:

mysql -ucb -p -H

In this line the -u flag stays for the username. Note that the username ‘cb’ is placed right after the flag with no space. The -p flag is for password. You could provide the password in plain text right after the flag, but that is quite a bad practice. So use the flag like it is and you’ll be prompted to type the password when you execute the command. The last flag -H is the hostname of the MySQL database server.

To connect remotely, meaning that the ‘mysql’ client is not running on the same machine as the servers, you might need to check the “Enable remote access to MySQL database

Follow the mysql tag for more MySQL related articles.