AMZ DIGICOM

Digital Communication

AMZ DIGICOM

Digital Communication

Install MySQL on Ubuntu 22.04: step by step instructions

PARTAGEZ

MySQL is an essential tool for database management. You can also use this software on Ubuntu. Discover with us the different steps to follow to install MySQL on Ubuntu 22.04.

What are the prerequisites for installing MySQL on Ubuntu?

The combination of Linux, Apache, MySQL and PHP is a very widespread solution, which is found for example in the field of LAMP servers. MySQL is therefore an open source database management system that plays a vital role in this stack. Since 1995, Oracle’s relational system has been one of the most used tools in the world for manage and structure data. Discover with us how to install MySQL on Ubuntu 22.04.

Do you want to learn how to master this software for your personal use? Do not hesitate to consult our detailed MySQL tutorial, provided for this purpose.

For installing MySQL on Ubuntu, the prerequisites are few. You must have an Ubuntu server, as well as root privileges. It is also necessary to configure a firewall with UFW (Uncomplicated Firewall). Then the installation is relatively simple. So that you don’t miss any essential steps, discover with us the entire procedure, with all the Linux commands you will need.

Web hosting with personal advisor!

Powerful, flexible and efficient web hosting with email, personal advisor and domain included 1time year !

Domain

SSL certificate

24/7 support

Step 1: Update your system

Before actually starting the installation of MySQL on Ubuntu 22.04 you must check that your system is up to date. The easiest way to do this is to use the Linux “apt” command. You can use it in the following ways:

$ sudo apt update
$ sudo apt list --upgradable
$ sudo apt upgrade

bash

Step 2: Install MySQL on Ubuntu 22.04

Everything is now ready for installing MySQL on Ubuntu 22.04. With the following command you will automatically obtain the latest available version of the software:

$ sudo apt install mysql-server

bash

Do you want to use a particular version? Start by using this command, which will give you an overview of all the options available to you:

$ sudo apt-cache mysql-server

bash

Wait a few moments for the installation to complete. To check if the server is working correctly, you can use the following command:

$ sudo systemctl start mysql.service

bash

So you have just installed MySQL on Ubuntu. However, the server is not yet configured. Given that this situation constitutes a considerable security risk, we advise you to take care of this step directly after installation. Once this is complete, you can start working with the new server. This will prevent you from receiving an error message from the system.

Step 3: Choose a Password

First choose a user password for MySQL. To do this, you can use the code below:

$ sudo mysql
ALTER USER ’root’@’localhost’ IDENTIFIED WITH mysql_native_password BY ’[Password]’;
mysql > exit

bash

Find a secure password and replace “ [Password] » (password) by the latter, removing the brackets. Make sure that the password is not displayed during and after your entry.

Step 4: Take Necessary Safety Measures

Now call the security script to make some essential settings. Below you will find the corresponding command:

$ sudo mysql_secure_installation

bash

The program then proceeds to the next steps. For example, it is possible to configure the password validation plugin, to check the performance of your password. If the user’s input is deemed too weak, then they must find a more secure password. To determine the performance of a password, you can enter “0” (low performance), “1” (medium performance), or “2” (high performance). The next step requires entering a password for the root user. This should not be displayed either. You can then confirm the new password. If you have enabled the password validation plugin, your desired performance is also checked.

Use “Y” to confirm other choices. This command allows, for example, to delete the test user registered at the start of the process, but also to delete the corresponding test database. If you do not want to make these deletions, use the “N” command.

Step 5: Change the Authentication Process

You can now close MySQL, allowing all these changes to take effect. Now open the program again and change the authentication process to the root user, using the initial “auth_socket” method. To do this, use the commands above:

$ mysql -u root -p
ALTER USER ’root’@’localhost’ IDENTIFIED WITH auth_socket;

bash

You will then be able to access MySQL again using the “sudo” command.

Step 6: Create an additional account

As the root account created by MySQL during its installation on Ubuntu 22.04 has important privileges, this access should only be used for administrative tasks. If you need to work in databases, we advise you to use another account instead. To create it with the necessary rights, you can use the commands below:

$ sudo mysql
CREATE USER ’Username’@’host’ IDENTIFIED WITH authentication_plugin BY ’Password’;

bash

It is up to you to choose the settings for “Username”, “host”, and “Password”, and replace them with the desired values. You can then assign certain privileges to this account. Below is the basic command to use to achieve this:

GRANT [Privileg] ON [Database].[Tabelle] TO ’Username’@’host’;

bash

Enter the privilege in question by removing the square brackets and indicate the database and table concerned in the correct location. The username and host should also be changed accordingly. To give an account several privileges, you can write them one after the other, separating them with commas. When you are finished, you can close MySQL. To log in with this account, in the future you will simply need to use the following command:

$ mysql -u Username -p

bash

Step 7: Check MySQL Status

MySQL Installation on Ubuntu 22.04 is now complete. To verify that the program is working well without any problems, do not forget to test its status using the following command:

$ systemctl status mysql.service

bash

Télécharger notre livre blanc

Comment construire une stratégie de marketing digital ?

Le guide indispensable pour promouvoir votre marque en ligne

En savoir plus

Souhaitez vous Booster votre Business?

écrivez-nous et restez en contact

Suivez-nous:

© 2024 AMZ DIGICOM All Rights Reserved