In this guide, we want to teach you How To Set up MySQL and Workbench on Ubuntu 20.04.
MySQL is an open-source Relational Database Management System (RDBMS) that uses Structured Query language(SQL) to interact with databases. You can use MySQL to store, retrieve, manipulate and process data that is in the form of tables.
MySQL Workbench is a unified cross-platform, open-source relational database design tool that adds functionality and ease to MySQL and SQL development work. MySQL Workbench provides data modeling, SQL development, and various administration tools for configuration. It also offers a graphical interface to work with the databases in a structured way.
How To Set up MySQL and Workbench on Ubuntu 20.04
To install MySQL and MySQL Workbench on your server, you must log in to your server as a non-root user with sudo privileges. To do this, you can follow our guide the Initial Server Setup with Ubuntu 20.04.
Now follow the steps below to install the latest MySQL and Workbench on Ubuntu 20.04.
Install MySQL 8.0 on Ubuntu 20.04
First, you need to download the MySQL Deb package from the MySQL Downloads page. To do this, run the command below:
Then, you need to install the package with the following command:
sudo apt install ./mysql-apt-config_*_all.deb
You will get the option to select what you want to add via the repository. You need to choose MySQL Server & Cluster, press the TAB button to select OK, and hit the Enter key.
Next, you need to choose the available version of MySQL on Ubuntu 20.04, here in our case it was MySQL 8.0.
Again Select OK and then use the TAB to move to OK and hit the Enter key.
This will automatically configure the latest Debian repository of the Database on your Ubuntu 20.04.
Note: If you want to add any additional tools using its repository or want to reconfigure it run the command below:
sudo dpkg-reconfigure mysql-apt-config
Update your local package index with the following command:
sudo apt update
Then, install MySQL on Ubuntu 20.04 with the following command:
sudo apt install mysql-server
You need to enter the password that you want to use with the MySQL server and then select the Strong authentication method:
Now you can start and enable your MySQL service on Ubuntu 20.04 with the command below:
sudo systemctl enable --now mysql
Verify that your MySQL service is active and running on your server with the following command:
sudo systemctl status mysql
Output ● mysql.service - MySQL Community Server Loaded: loaded (/lib/systemd/system/mysql.service; enabled; vendor preset:> Active: active (running) since Sat 2022-06-25 11:06:43 CEST; 2min 36s ago Docs: man:mysqld(8) http://dev.mysql.com/doc/refman/en/using-systemd.html Main PID: 2551 (mysqld) Status: "Server is operational" Tasks: 37 (limit: 2282) Memory: 355.9M CGroup: /system.slice/mysql.service └─2551 /usr/sbin/mysqld
To see your MySQL version, you can run the command below:
Output mysql Ver 8.0.29 for Linux on x86_64 (MySQL Community Server - GPL)
Secure MySQL Installation
At this point, you secure your MySQL by running the MySQL secure script:
You will be asked to enter the root password. Also, you will be asked to set a validate password component. And you will be asked if you want to change your root password. Answer them as your wish from there type y to continue.
At this point, you can access your MySQL shell with the following command:
sudo mysql -u root -p
Enter password: Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 10 Server version: 8.0.29 MySQL Community Server - GPL Copyright (c) 2000, 2022, Oracle and/or its affiliates. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. mysql>
Install MySQL Workbench on Ubuntu 20.04
Now, it’s time to install MySQL workbench.
To do that, execute the following command to install MySQL workbench.
sudo snap install mysql-workbench-community
Output mysql-workbench-community 8.0.25 from Tonin Bolzan (tonybolzan) installed
Once the installation is complete, you will finally launch the MySQL
Workbench on your system. You can launch it using the terminal by typing
the following command:
Or, you can move to the “Applications” menu and search for the MySQL workbench application and open it.
Congratulations! You have successfully installed MySQL Workbench on Ubuntu 22.04 system.
At this point, you learn to Set up MySQL and Workbench on Ubuntu 20.04.
Hope you enjoy using it.
You may be interested in these articles:
Install and Configure Joomla on Ubuntu 20.04
Install and Configure SVN Server on Ubuntu 22.04