How to Install 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.
Then, install the repository package using the
sudo dpkg -i mysql-apt-config_0.8.23-1_all.deb
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
Manage MySQL Server Service
After installing the MySQL server, run the below command to check the status MySQL database service.
sudo systemctl status mysql
● 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: Starting MySQL Community Server... Jul 31 02:14:51 ubuntu-2204 systemd: 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
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>
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.
That’s All. I hope you have learned how to install MySQL on Ubuntu 22.04.