In thesecond articleof theseries uncovering how to get started with MySQL, we talk about the ways of connecting to MySQL Server.
You can connect to MySQL Server using MySQL Client, dbForge Studio for MySQL, and MySQL Workbench. In this article, we consider each method in detail.
Connecting to MySQL Using the MySQL Command-Line Client
Connecting to MySQL Using dbForge Studio for MySQL
Connecting to MySQL Using MySQL Workbench
Connecting to MySQL Using the MySQL Command-Line Client
In the first article of our series, we provided a detailed walkthrough outlining the aspects of how to install MySQL Server on Windows. In this guide, we build on the fact that your MySQL server is up and running.
To connect to MySQL Server:
- Locate the MySQL Command-Line Client
MySQL server is usually installed together with a console client for working with databases. On Windows, you can find the MySQL Command Line Client in the Start menu. Please note, that the client is installed in two versions – with the support for Unicode and without it.
- Run the client
When you run the MySQL Server Command-Line Client, the command prompt window opens asking you to enter a password.
- Enter your password
Here, you need to login to MySQL from the Command line by entering the password that was set for the root user during the MySQL installation.
In case of a successful connection, you see something similar to this: - Get a list of databases
Enter the show databases command to get a list of databases on our MySQL Server.
- Create a database
To create a new database, use the create database command.
- Select the database you want to use
To connect to a specific MySQL database, at theMySQLprompt, typethe use database command and specify the name of the database you want to use.
- Create a table and insert data
Use the create table and insert into commands to create a table in our database and insert data into it.
- Finish working with the MySQL Command-Line Client
To leave the MySQL client, type quit at the prompt and press Enter.
Connecting to MySQL Using dbForge Studio for MySQL
dbForge Studio for MySQL is a premium all-in-one MySQL GUI tool, allowing you to develop, manage, and administer MySQL databases in the feature-rich environment. With dbForge Studio for MySQL, you can quickly and easily set up a remote database connection as well as connect to your local server.
To connect to MySQL Server using Studio for MySQL:
1. Open the Database Connection Properties dialog box in one of the following ways:
clickNew Connectionon theDatabasemenu
or
click theNew Connectionbutton on theConnectiontoolbar.
2. Select the connection type in theTypebox. There are two connection types available: TCP/IP and Named pipe.
3. Enter the host name in theHostbox.
4. For a TCP/IP connection, enter the port information in thePortbox. The default port number is 3306. For a Named pipe connection, enter the pipe name in thePipebox.
5. Enter the login credentials in theUserandPasswordfields.
6. Inthe Database field, type or select the name of the database to which you want to connect.
7. TheConnection Namewill be generated automatically from the Host name. However, you can create a distinctive name for your new connection, if required.
![How to Connect to MySQL Server - Devart Blog (10) How to Connect to MySQL Server - Devart Blog (10)](https://i0.wp.com/blog.devart.com/wp-content/uploads/2021/02/studio-connection-properties.png)
8. (Optional step). You can clickAdvancedto configure advanced connection properties. On the Advanced tab, you can specify Connection timeout and Execute timeout values in seconds. Here, you can also select the Encoding type from a drop-down list and enable the Detect MySQL character set, Use compression, and Keep connection alive options.
![How to Connect to MySQL Server - Devart Blog (11) How to Connect to MySQL Server - Devart Blog (11)](https://i0.wp.com/blog.devart.com/wp-content/uploads/2021/02/advanced-connection-options.png)
9. (Optional step). You can clickthe Securitytab to configure security properties. On this tab, you can set up SSL or SSH security properties.
![How to Connect to MySQL Server - Devart Blog (12) How to Connect to MySQL Server - Devart Blog (12)](https://i0.wp.com/blog.devart.com/wp-content/uploads/2021/02/security-connection-properties.png)
10. (Optional step). You can go to the HTTP tab, to configure HTTP tunnel properties.
![How to Connect to MySQL Server - Devart Blog (13) How to Connect to MySQL Server - Devart Blog (13)](https://i0.wp.com/blog.devart.com/wp-content/uploads/2021/02/http-connection-properties.png)
11. (Optional step). ClickTest Connectionto verify that you can access MySQL Server using the connection information you’ve specified.
12. ClickOKto create the connection.
As you can see, dbForge Studio for MySQL offers a visual and straightforward method to connect to MySQL Server. It also gives you more control over connection configurations.
Connecting to MySQL Using MySQL Workbench
MySQLWorkbenchis a popular unified visual tool for database architects, developers, and DBAs.
To access MySQL Server using Workbench:
1. Run MySQL Workbench.
2. On the Database menu, click Connect to Database.
Alternatively, click the plus icon next to MySQL Connections label.
![How to Connect to MySQL Server - Devart Blog (14) How to Connect to MySQL Server - Devart Blog (14)](https://i0.wp.com/blog.devart.com/wp-content/uploads/2021/02/workbench-connection.png)
3. In the Connect to Database window that appears, specify the Connection name as well as provide the host name, port, and user values.
![How to Connect to MySQL Server - Devart Blog (15) How to Connect to MySQL Server - Devart Blog (15)](https://i0.wp.com/blog.devart.com/wp-content/uploads/2021/02/workbench-setup-connection.png)
4. (Optional step). Go to the SSL tab to configure SSL connection settings.
![How to Connect to MySQL Server - Devart Blog (16) How to Connect to MySQL Server - Devart Blog (16)](https://i0.wp.com/blog.devart.com/wp-content/uploads/2021/02/ssl-workbench.png)
5. (Optional step). Go to the Advanced tab to configure advanced connection settings.
![How to Connect to MySQL Server - Devart Blog (17) How to Connect to MySQL Server - Devart Blog (17)](https://i0.wp.com/blog.devart.com/wp-content/uploads/2021/02/workbench-advanced.png)
6. Optionally, you can click Test Connection to check the parameters that you’ve entered. In case you are sure that all the credentials are correct, click OK.
7. Enter a password.
![How to Connect to MySQL Server - Devart Blog (18) How to Connect to MySQL Server - Devart Blog (18)](https://i0.wp.com/blog.devart.com/wp-content/uploads/2021/02/password-workbench.png)
7. In case you’ve successfully connected to MySQL Server, you will see a list of databases on the left.
![How to Connect to MySQL Server - Devart Blog (19) How to Connect to MySQL Server - Devart Blog (19)](https://i0.wp.com/blog.devart.com/wp-content/uploads/2021/02/connection-successful.png)
Conclusion
In this article, we have presented three ways to connect to MySQL Server. Both dbForge Studio for MySQL and MySQL Workbench boast visual and comprehensive connection wizards enabling you to smoothly connect to MySQL Server in seconds. Both solutions have the capabilities to configure advanced settings.
dbForge Studio for MySQL is a worthy alternative to MySQL Workbench. Moreover, in many aspects, it is superior in functionality.
Along with dbForge Studio for MySQL, dbForge database tools for MySQL also have visual and user-friendly connection wizards that help connect to MySQL Server and a specific database quickly and easily.