How To Install MySQL 8.0 on Ubuntu 20.04 | Holhol24

3

MySQL is an open-source database server commonly used in a three-tier application to store and retrieve records and information. It is developed by Oracle Corporation.

MySQL was the primary database server for Linux operating system until
MariaDB, a fork of MySQL, came into the picture.

Here, we will see how to install
MySQL 8.0 on
Ubuntu 20.04.

Install MySQL 8.0 on Ubuntu 20.04

MySQL is now available in both Ubuntu repository and MySQL Dev repository. Both Ubuntu & MySQL community offers only MySQL v8.0 for Ubuntu 20.04.

Install MySQL 8.0 From Ubuntu Repository

Installing MySQL server 8.0 from the Ubuntu repository is a straight forward one.

Update the repository index.

sudo apt update

Use the
apt command to install the MySQL database server.

sudo apt install -y mysql-server-8.0 mysql-client-8.0

Use the mysql_secure_installation command to set the MySQL root password and other security settings to secure the MySQL instance.

sudo mysql_secure_installation
Output:

Securing the MySQL server deployment.

Connecting to MySQL using a blank password.

VALIDATE PASSWORD COMPONENT 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 component?

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: 2  
Please set the password for root here.

New password: xxx  

Re-enter new password: xxx  

Estimated strength of the password: 100
Do you wish to continue with the password provided?(Press y|Y for Yes, any other key for No) : Y  
By default, a MySQL installation has an anonymous user,
allowing anyone to log into MySQL without having to have
a user account created for them. This is intended only for
testing, and to make the installation go a bit smoother.
You should remove them before moving into a production
environment.

Remove anonymous users? (Press y|Y for Yes, any other key for No) : Y  
Success.


Normally, root should only be allowed to connect from
'localhost'. This ensures that someone cannot guess at
the root password from the network.

Disallow root login remotely? (Press y|Y for Yes, any other key for No) : Y  
Success.

By default, MySQL comes with a database named 'test' that
anyone can access. This is also intended only for testing,
and should be removed before moving into a production
environment.


Remove test database and access to it? (Press y|Y for Yes, any other key for No) : Y  
 - Dropping test database...
Success.

 - Removing privileges on test database...
Success.

Reloading the privilege tables will ensure that all changes
made so far will take effect immediately.

Reload privilege tables now? (Press y|Y for Yes, any other key for No) : Y  
Success.

All done!

MySQL 8.0 uses a new authentication based on improved SHA 256 password methods. Due to the new authentication mechanism, old clients built with libmysqlclient may not be able to connect to the database server.

You can change the default authentication plugin any time by setting the below in the configuration /etc/mysql/my.cnf file.

[mysqld]
default-authentication-plugin=mysql_native_password

Install MySQL 8.0 From MySQL Dev

Download the MySQL repository configuration package on your system.

wget https://dev.mysql.com/get/mysql-apt-config_0.8.15-1_all.deb

Install the repository package using the dpkg command.

sudo dpkg -i mysql-apt-config_0.8.15-1_all.deb

The package installer will prompt you to select the
MySQL repository. Since MySQL community offers only MySQL v8.0, just select OK and then press Enter.

MySQL 8.0 Repository

Update the repository index using the
apt command.

sudo apt update

Use the
apt command to install the
MySQL database server

sudo apt install -y mysql-server mysql-client

The package installer will prompt you to set the MySQL root password.

Skip setting the MySQL root password by just pressing the enter button. When you leave the password blank, you can log in as MySQL root user only from the Unix terminal (# or sudo).

Set MySQL Root Password How To Install MySQL 8.0 on Ubuntu 20.04 | Holhol24 How To Install MySQL 8.0 on Ubuntu 20.04 | Holhol24 1605831471 479 How To Install MySQL 80 on Ubuntu 2004 Holhol24
Set MySQL Root Password

Re-enter the password.

Re-enter MySQL Root Password How To Install MySQL 8.0 on Ubuntu 20.04 | Holhol24 How To Install MySQL 8.0 on Ubuntu 20.04 | Holhol24 1605831471 963 How To Install MySQL 80 on Ubuntu 2004 Holhol24
Re-enter MySQL Root Password

MySQL 8.0 uses a new authentication based on improved SHA 256 password methods. If you choose this option, old clients may not be able to connect to the server.

Default Authentication Plugin How To Install MySQL 8.0 on Ubuntu 20.04 | Holhol24 How To Install MySQL 8.0 on Ubuntu 20.04 | Holhol24 1605831471 282 How To Install MySQL 80 on Ubuntu 2004 Holhol24
Default Authentication Plugin

You can change the default authentication plugin any time by setting the below in the configuration /etc/mysql/my.cnf file.

[mysqld]
default-authentication-plugin=mysql_native_password

Use the mysql_secure_installation command to make this MySQL instance more secure.

sudo mysql_secure_installation
Output:

Securing the MySQL server deployment.

Enter password for user root: xxx 

VALIDATE PASSWORD COMPONENT 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 component?

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: 2  
Using existing password for root.

Estimated strength of the password: 100
Change the password for root ? ((Press y|Y for Yes, any other key for No) : N  

 ... skipping.
By default, a MySQL installation has an anonymous user,
allowing anyone to log into MySQL without having to have
a user account created for them. This is intended only for
testing, and to make the installation go a bit smoother.
You should remove them before moving into a production
environment.

Remove anonymous users? (Press y|Y for Yes, any other key for No) : Y  
Success.


Normally, root should only be allowed to connect from
'localhost'. This ensures that someone cannot guess at
the root password from the network.

Disallow root login remotely? (Press y|Y for Yes, any other key for No) : Y 
Success.

By default, MySQL comes with a database named 'test' that
anyone can access. This is also intended only for testing,
and should be removed before moving into a production
environment.


Remove test database and access to it? (Press y|Y for Yes, any other key for No) : Y 
 - Dropping test database...
Success.

 - Removing privileges on test database...
Success.

Reloading the privilege tables will ensure that all changes
made so far will take effect immediately.

Reload privilege tables now? (Press y|Y for Yes, any other key for No) : Y 
Success.

All done!

Work with MySQL Server

Log in to the MySQL server.

mysql -u root -p

Prefix sudo to log in as MySQL root user without entering a password in case you have installed MySQL 8.0 from the Ubuntu repository.

Welcome to the MySQL monitor.  Commands end with ; or g.
Your MySQL connection id is 14
Server version: 8.0.20 MySQL Community Server - GPL

Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved.

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>

Conclusion

That’s All. I hope you have learned how to install
MySQL 8.0 on
Ubuntu 20.04. If you are new to MySQL databases, use
phpMyAdmin to manage them over a web browser.

This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish. Accept Read More