Connect to MySQL Server
If this site saves you hours of work, please whitelist it in your ad blocker or
to support us creating more free content in the future.
Summary: in this tutorial, you will learn how to connect to MySQL Server using mysql command-line client and MySQL Workbench.
Once you have the
MySQL Server installed
, you can connect to it using any client program such as mysql command-line client and MySQL workbench.
Connect to MySQL Using mysql command-line client
mysql is a command-line client program that allows you to interact with MySQL in the interactive and non-interactive mode.
The mysql command-line client is typically located in the bin directory of the MySQL’s installation folder.
To invoke the mysql program, you just simply navigate to the bin directory of the MySQL’s installation folder and type:
If the mysql program is already in the PATH, you can simply invoke it using mysql command.
To connect to the MySQL Server, you use this command:
shell>mysql -u root -p
-u root means that you connect to the MySQL Server using the user account root.
-p instructs mysql to prompt for a password.
You type the password for the user account root and press Enter:
Enter password: ********
If everything is OK, you will connect to the MySQL Server with the following command:
To display the databases in the current server, you use the
mysql> show databases;
Here is the output:
| Database |
| information_schema |
| mysql |
| performance_schema |
| sys |
4 rows in set (0.01 sec)
Connect to MySQL Using MySQL Workbench
Step 1. Launch the MySQL Workbench.
You can connect to a MySQL Server using the Database > Connect to Database… menu or click the + button that locates next to the MySQL Connections.
Just click the + button in next to the MySQL Connections to continue.
Step 2. Enter the connection name e.g., Localhost. You can name it whatever makes sense to you. By default, the username is root. If you use a different user account, you can change it in the Username textbox.
Step 3. Click the Store in Vault … button to enter the password for the provided user account. A window will display. You enter the password and click the OK button.
Step 4. Click the Test Connection button to test if the connection to the MySQL Server is successful or not. Then click the OK button if the connection is established successfully.
Step 5. Click the OK button to save the connection.
Step 6. Click the newly created connection under MySQL Connections to connect to the MySQL Server:
Step 7. MySQL Workbench display with the current schemas and a pane for entering queries:
In this tutorial, you have learned how to connect to the MySQL Server using mysql command-line client and MySQL Workbench.
Delivering a high-quality product at a reasonable price is not enough anymore.
That’s why we have developed 5 beneficial guarantees that will make your experience with our service enjoyable, easy, and safe.
You have to be 100% sure of the quality of your product to give a money-back guarantee. This describes us perfectly. Make sure that this guarantee is totally transparent.Read more
Each paper is composed from scratch, according to your instructions. It is then checked by our plagiarism-detection software. There is no gap where plagiarism could squeeze in.Read more
Thanks to our free revisions, there is no way for you to be unsatisfied. We will work on your paper until you are completely happy with the result.Read more
Your email is safe, as we store it according to international data protection rules. Your bank details are secure, as we use only reliable payment systems.Read more
By sending us your money, you buy the service we provide. Check out our terms and conditions if you prefer business talks to be laid out in official language.Read more