Connect to MySQL Server Using Command Line

In this tutorial, you will learn how to connect to MySQL server using the command line.

To connect to MySQL Server, you can use following command:

$ mysql -u[username] -h[server_host] -p

Following is the sample that trying to connect to local MySQL Server:

$ mysql -u root -p

or

$ mysql -u root -h localhost -p

It will prompt you for the password of the user, type the password and press ENTER.

You will see following output when connect to MySQL server successfully:

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.