Setting Up MySQL, MySQL Workbench, and Connecting to Your Database
Setting Up MySQL, MySQL Workbench, and Connecting to Your Database
Estimated Read Time: 20 Minutes
Installing MySQL and MySQL Workbench
Install MySQL
Follow these steps to install MySQL on your machine…
For Windows:
- Go to the MySQL Downloads Page.
- Download the MySQL Installer and run it.
- Choose the “Developer Default” setup.
- Set the root password during installation and remember it!
For macOS:
- Download the MySQL Community Server from MySQL website.
- Run the `.dmg` file and follow the instructions.
For Linux:
sudo apt update sudo apt install mysql-server sudo systemctl status mysql
Install MySQL Workbench
- Go to the MySQL Workbench Downloads Page.
- Download and install the version matching your OS.
Connecting to MySQL Database Using MySQL Workbench
Create a New Connection
- Open MySQL Workbench.
- Click on the “+” sign next to “MySQL Connections” to create a new connection.
- Enter connection details such as Connection Name, Hostname (localhost), and Username (root).
- Click “Test Connection” to verify everything is working.
Connecting to Your Database
Once the connection is set up, click on the connection name to open MySQL Workbench…
Creating a New Database
To create a new database, right-click on the Schemas panel and choose “Create Schema”. Enter a name and click Apply.
Running SQL Queries
CREATE TABLE Employees ( employee_id INT PRIMARY KEY, first_name VARCHAR(50), last_name VARCHAR(50), department_id INT );
Connecting to a Remote MySQL Database
To connect to a remote database, provide the IP address or domain name of the server and the necessary credentials.
Conclusion
Now that you have MySQL installed and know how to connect to your database, you can start working on SQL queries and database management!