In today’s developing world and big data ecosystem, MySQL has become one of the most well-known technologies and is one of the most popular databases in many industries. If you want to master this database, you only need a basic understanding. MYSQL can be used on various Linux distributions and one of these distros is Ubuntu. Here, we will be going to show the best way to install MYSQL on Ubuntu 22.04. Keep studying carefully.
MySQL is an open-source database management system that is usually installed as a part of the popular LAMP stack. As you learn how to install MySQL, you will have a working relational database to build your next website or application. Now, follow the instructions step-by-step to install MySQL on Ubuntu Linux VPS.
To install MySQL you will need the following requirements:
To start the installation process, first of all, you should update the system repository. Press CTRL+ALT+T to open a terminal on Ubuntu. Now run the command below to update the system repository:
sudo apt update
Now you can run the following command to install MySQL on your system:
sudo apt-get install mysql-server
You need a few minutes to complete the installation and continue.
Note that you can verify MySQL status using the following command:
systemctl is-active MySQL
The installation was straightforward and simple. So you can configure it on your system.
If you want to perform an initial and interactive configuration of your MySQL server, you can execute the command line below:
sudo mysql_secure_installation
At the beginning of the configuration step, you will be asked to set the level for the password validation policy. So, according to your validation requirements, choose a number from the menu in front of you.
Now enter the new password for root and press Y to continue the process with your new password:
Finally, do the rest of the configuration section accordingly:
Now, create a native password for the root by logging into the MySQL server and setting the default authentication method to “mysql_native_password”:
sudo MySQL
Now you will see a query that sets the root password to “Password123#@!” and determines the authentication method to “mysql_native_password“:
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'Password123#@!';
To be able to apply the changes without restarting the MySQL service, you can reload the grant table in the MySQL database:
FLUSH PRIVILEGES;
Now, you can login to the MySQL server with your new password and enjoy the server.
Now that you have installed MySQL successfully, you can ensure MySQL service is active and running with the following command:
systemctl status mysql.service
That’s it! Login to MySQL and use this great database as you wish.
Like any software, it can encounter various issues. Here are some common issues with MySQL on Ubuntu and their potential solutions:
1- You cannot connect to the MySQL server.
Solutions:
2- You’ve forgotten the MySQL root password.
Solutions:
Stop MySQL:
sudo service mysql stop.
Start MySQL in safe mode:
sudo mysqld_safe --skip-grant-tables.
Connect to MySQL:
mysql -u root.
Change the root password:
UPDATE mysql.user SET authentication_string = PASSWORD('new_password') WHERE User = 'root'; FLUSH PRIVILEGES;.
Stop MySQL safe mode:
sudo service mysql stop.
3- Your MySQL database is corrupted.
Solutions:
4- Running out of disk space can cause MySQL to stop working.
Solutions:
5- MySQL fails to start
Solutions:
As mentioned, MySQL is a popular database. In this article, we examined how to install it in Ubuntu and explained to you from updating the repositories to configuring and running it. So that you can enter the MySQL server by setting a new password and using it. We hope that the above information is useful for you. Happy coding!
How useful was this post?
Click on a star to rate it!
Average rating 0 / 5. Vote count: 0
No votes so far! Be the first to rate this post.
CUDA is a parallel computing platform and API model developed by Nvidia for general-purpose computin...
ROXTerm is a versatile and powerful terminal emulator for Unix-like systems such as Ubuntu. It provi...
What is your opinion about this Blog?