How to Install MySQL on Ubuntu 22.04

0
140

 

MySQL on Ubuntu 22.04

MySQL is a fee relational database management system from Oracle, and it is released under the GPL (General Public License).

It was initially developed by a Swedish company, MySQL AB,  and is now owned and developed by the Oracle Corporation.

This article will show how to install MySQL on Ubuntu 22.04.

Install MySQL Server on Ubuntu 22.04

Install MySQL 8.0 on Ubuntu 22.04

MySQL database packages are available through Oracle’s official repository. So, first, download the MySQL repository setup package for Ubuntu.

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

Then, install the repository package using the dpkg command.

sudo dpkg -i mysql-apt-config_0.8.23-1_all.deb
MySQL version 8.0 is the default selection for the repository’s configuration. Use the down arrow to choose OK and then press Enter.

And then update the repository index using the apt command.

sudo apt update

Finally, run the following command to install MySQL server 8.0.

sudo apt install -y mysql-community-server

The package installer will prompt you to,

1. Enter MySQL root password

2. Re-Enter MySQL root password

3. Choose Authentication Method

Use Strong Password Encryption (RECOMMENDED): MySQL will use a new authentication based on the SHA256 password methods. If you choose this method, only the latest version of clients and connectors with caching_sha2_password support can connect to the MySQL server.

Use Legacy Authentication Method (Retain MySQL 5.x Compatibility): MySQL will use the old authentication method (mysql_native_password), which all clients and connectors support.

Install MySQL 5.7 on Ubuntu 22.04

MySQL 5.7 packages are not available for Ubuntu 22.04. So, you can not install MySQL server 5.7 on Ubuntu 22.04.

Manage MySQL Server Service

After installing the MySQL server, run the below command to check the status MySQL database service.

sudo systemctl status mysql

Output:

 mysql.service - MySQL Community Server
     Loaded: loaded (/lib/systemd/system/mysql.service; enabled; vendor preset: enabled)
     Active: active (running) since Sun 2022-07-31 02:14:51 EDT; 24s ago
       Docs: man:mysqld(8)
             http://dev.mysql.com/doc/refman/en/using-systemd.html
   Main PID: 5548 (mysqld)
     Status: "Server is operational"
      Tasks: 39 (limit: 4624)
     Memory: 357.0M
        CPU: 779ms
     CGroup: /system.slice/mysql.service
             └─5548 /usr/sbin/mysqld

Jul 31 02:14:50 ubuntu-2204 systemd[1]: Starting MySQL Community Server...
Jul 31 02:14:51 ubuntu-2204 systemd[1]: Started MySQL Community Server.

You can stop/start/restart the MySQL server service with the below commands.

sudo systemctl stop mysql

sudo systemctl start mysql

sudo systemctl restart mysql

Login to MySQL Server

Login to the MySQL database server with the MySQL root user and the password you set during installation.

mysql -u root -p

Output

Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 8
Server version: 8.0.30 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 phpMyAdmin

PHPMyAdmin is a web-based tool for managing MySQL and MariaDB servers over the web browser. It provides an interface for performing administrative operations on your database like creating, dropping, altering, deleting databases and tables, etc.

Conclusion

That’s All. I hope you have learned how to install MySQL on Ubuntu 22.04.

 

Do you find AfroNaija useful? Click here to give us five stars rating!

LEAVE A REPLY

Please enter your comment!
Please enter your name here