How To Install MySQL 8.0 on Ubuntu 22.04|20.04

  • MySQL Document Store
  • SQL Roles
  • Transactional Data Dictionary
  • Default to utf8mb4
  • Common Table Expressions
  • Window Functions
  • And many more.

Step 1: Add MySQL APT repository

wget https://dev.mysql.com/get/mysql-apt-config_0.8.22-1_all.deb
sudo dpkg -i mysql-apt-config_0.8.22-1_all.deb
install-mysql-server-ubuntu-01-1024x251
How-to-install-mysql-8.0-on-ubuntu-20.04-06-1024x181
How-to-install-mysql-8.0-on-ubuntu-20.04-01-1024x156

Step 2: Update MySQL Repository

sudo apt update
### Ubuntu 22.04 ###

$ apt-cache policy mysql-server

mysql-server:

Installed: (none)

Candidate: 8.0.29-0ubuntu0.22.04.2

Version table:

8.0.29-0ubuntu0.22.04.2 500

500 http://ke.archive.ubuntu.com/ubuntu jammy-updates/main amd64 Packages

500 http://ke.archive.ubuntu.com/ubuntu jammy-updates/main i386 Packages

500 http://security.ubuntu.com/ubuntu jammy-security/main amd64 Packages

500 http://security.ubuntu.com/ubuntu jammy-security/main i386 Packages

8.0.28-0ubuntu4 500

500 http://ke.archive.ubuntu.com/ubuntu jammy/main amd64 Packages

500 http://ke.archive.ubuntu.com/ubuntu jammy/main i386 Packages



### Ubuntu 20.04 ###

$ sudo apt-cache policy mysql-server

mysql-server:

Installed: (none)

Candidate: 8.0.29-1ubuntu20.04

Version table:

8.0.29-1ubuntu20.04

500 http://repo.mysql.com/apt/ubuntu focal/mysql-8.0 amd64 Packages

Step 3: Install MySQL 8.0 on Ubuntu22.04|20.04

sudo apt install mysql-client mysql-server
sudo apt install mysql-client mysql-community-server mysql-server
Need to get 35.3 MB of archives.

After this operation, 311 MB of additional disk space will be used.

Do you want to continue? [Y/n] y
install-mysql-server-ubuntu-02-1024x194
install-mysql-server-ubuntu-03-1024x272
install-mysql-server-ubuntu-04-1024x241

Step 4: Secure MySQL Installation

sudo mysql_secure_installation
Enter current password for root (enter for none): 

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) : n





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!

Step 5) Validate MySQL 8.0 Installation

$ mysql -u root -p

Enter password:

Welcome to the MySQL monitor. Commands end with ; or \g.

Your MySQL connection id is 9

Server version: 8.0.27 MySQL Community Server - GPL



Copyright (c) 2000, 2021, 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>
mysql> SELECT VERSION();

+-----------+

| VERSION() |

+-----------+

| 8.0.27 |

+-----------+

1 row in set (0.00 sec)

Creating MySQL Database and User (Optional)

CREATE DATABASE mydb;

CREATE USER 'mydbuser'@'%' IDENTIFIED BY 'DBUserStr0ngPassw0d.';

GRANT ALL PRIVILEGES ON mydb.* TO 'mydbuser'@'%';

FLUSH PRIVILEGES;

exit

Step 6: Enabling MySQL remote access (Optional)

sudo vim /etc/mysql/mysql.conf.d/mysqld.cnf
# By default we only accept connections from localhost 

#bind-address = 127.0.0.1

bind-address = 0.0.0.0
sudo systemctl restart mysql
sudo ufw allow from  to any port 3306

sudo ufw enable
$ mysql -u user -h database_server_ip -p

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
ComputingPost

ComputingPost

ComputingPost — Linux Howtos, Tutorials, Guides, News, Tips and Tricks.