You can download this article in PDF format via the link below to support us.Download the guide in PDF formatClose
Today’s guide describes the process of installing MySQL 8.0 on Ubuntu 20.04. MySQL is one of the most commonly used database management systems. It uses the concept of relational database and has a client/server architecture. It can be installed on various operating systems, including Windows, CentOS and Debian.
Install MySQL 8.0 on Ubuntu 20.04
The following steps describe how to install and configure MySQL 8.0 on Ubuntu 20.04.
Step 1: Add MySQL APT repository in Ubuntu
Ubuntu already comes with a default MySQL package repository. In order to add or install the latest repository, we will install the package repository. Use the following command to download the repository:
After downloading, install the repository by running the following command:
sudo dpkg -i mysql-apt-config_0.8.12-1_all.deb
At the prompt, select Ubuntu’s Bionic then click it is good
His next prompt shows MySQL 8.0 selected by default.Select the first option and click it is good
In the next prompt, select MySQL 8.0 Server and click it is good.
By default, the next prompt selects MySQL8.Choose the last option it is good then click it is good.
Step 2: Update the MySQL system repository on Ubuntu 20.04
Run the following command to update the system package index list.
sudo apt-get update
Now search for MySQL 8.0 using apt cache, as shown below:
$ sudo apt-cache policy mysql-server mysql-server: Candidate: 8.0.21-1ubuntu18.04 Version table: 8.0.21-1ubuntu18.04 500 500 http://repo.mysql.com/apt/ubuntu bionic/mysql-8.0 amd64 Packages 8.0.21-0ubuntu0.20.04.4 500 500 http://ke.archive.ubuntu.com/ubuntu focal-updates/main amd64 Packages 500 http://ke.archive.ubuntu.com/ubuntu focal-security/main amd64 Packages 8.0.19-0ubuntu5 500 500 http://ke.archive.ubuntu.com/ubuntu focal/main amd64 Packages *** 5.7.31-1ubuntu18.04 100 100 /var/lib/dpkg/status
Step 3: Install MySQL 8.0 on Ubuntu 20
After finding MySQL 8.0 in our system, we will install MySQL 8.0 client and MySQL 8.0 server using the following commands:
sudo apt install -f mysql-client=8.0.21-1ubuntu18.04 mysql-community-server=8.0.21-1ubuntu18.04 mysql-server=8.0.21-1ubuntu18.04
Enter and re-enter the root password when prompted
Secure MySQL installation
Run the following command to protect MySQL
$ sudo mysql_secure_installation
press enter.When prompted for a password, provide the root password set above
Enter current password for root (enter for none): <Enter password> VALIDATE PASSWORD PLUGIN can be used to test passwords and improve security. It checks the strength of password and allows the users to set only those passwords which are secure enough. Would you like to setup VALIDATE PASSWORD plugin? Press y|Y for Yes, any other key for No: Y There are three levels of password validation policy: LOW Length >= 8 MEDIUM Length >= 8, numeric, mixed case, and special characters STRONG Length >= 8, numeric, mixed case, special characters and dictionary file Please enter 0 = LOW, 1 = MEDIUM and 2 = STRONG: 1 Using existing password for root. Estimated strength of the password: 25 Change the password for root ? ((Press y|Y for Yes, any other key for No) : d Remove anonymous users? [Y/n] Y Disallow root login remotely? [Y/n] Y Remove test database and access to it? [Y/n] Y Reload privilege tables now? [Y/n] Y Thanks for using MariaDB!
Check MySQL version
Connect to MySQL to check the MySQL installation version. To connect to MySQL, run the following command:
mysql-u root -p
Provide the root password set above, once connected, execute the following command to display the MySQL version.
SELECT VERSION() | VERSION() | +-----------+ | 8.0.21 | +-----------+ 1 row in set (0.00 sec)
Step 4: Create MySQL user (optional)
While still connected to MySQL, run the following command to create a user:
CREATE USER 'lorna'@'%' IDENTIFIED BY 'MyStrongPass.'; GRANT ALL PRIVILEGES ON * . * TO 'lorna'@'%'; FLUSH PRIVILEGES; exit
Step 5: Enable MySQL remote access (optional)
By default, MySQL remote access is disabled. To enable it, we need to edit the mysqld.cnf file as follows:
$ sudo vim /etc/mysql/mysql.conf.d/mysqld.cnf
Find the “bind_address” line and make the following changes:
# By default we only accept connections from localhost #bind-address = 127.0.0.1 bind-address = 0.0.0.0
Save the file and restart mysql
$ sudo systemctl restart mysql
Allow remote connections through the firewall
$ sudo ufw allow from <remote_IP_address> to any port 3306 $ sudo ufw enable
To access the database from a remote computer, run the following command:
$ mysql -u user -h database_server_ip -p
That was about installing mySQL 8.0 on Ubuntu 20.04. Here are more guides that you will be interested in!
- How to install MySQL 5.7 on Ubuntu
- How to install MySQL 8.0 on Kali Linux
- How to install MySQL 5.7 on CentOS 8 / RHEL 8 Linux
- How to install MySQL 8.0 on CentOS 8 / RHEL 8 Linux
- How to install MariaDB on CentOS 8 | centOS 7
Database learning video:
★★★★★ (63287) $ 12.98 $ 153.38 in stock
★★★★★ (45577) $ 15.34 $ 176.97 in stock
★★★★★ (80355) $ 12.98 $ 153.38 in stock
Udemy.com You can support us by downloading the article in PDF format from the link below.Download the guide in PDF formatClose