MySQL is a widely-used open-source relational database management system (RDBMS). It is based on the Structured Query Language (SQL) and is often used in conjunction with PHP and other programming languages to build dynamic websites and web-based applications. In this tutorial, we will show you how to install MySQL on Ubuntu Server OS.
1.Update the package list
To ensure that you have the latest version of MySQL, you should update the package list on your system. Open the terminal and run the following command:
sudo apt-get update
2.Install MySQL
To install MySQL, run the following command:
sudo apt-get install mysql-server
During the installation process, you will be prompted to set a root password for the MySQL server. Make sure to choose a strong and secure password.
3.Verify the installation
To verify that the installation was successful, check the MySQL service status by running the following command:
sudo systemctl status mysql
You should see an output indicating that the service is active and running.
4.Secure the Installation
MySQL provides a script called mysql_secure_installation that can be used to improve the security of your MySQL installation. To run the script, enter the following command:
sudo mysql_secure_installation
You will be prompted to answer several questions about how to secure your MySQL installation. It is recommended to answer yes to all questions.
OUTPUT: Securing the MySQL server deployment. Connecting to MySQL using a blank password. VALIDATE PASSWORD COMPONENT 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 component? 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:
After choosing validation policy, the next prompt will be to set for mysql password, and retype the password for confirmation
OUTPUT: Please set the password for root here. New password: Re-enter new password:
5.Log in to MySQL
Once the installation is complete, you can log in to the MySQL server by running the following command:
sudo mysql -u root -p
Enter the root password that you set during the installation process when prompted.
Congratulations, you have successfully installed MySQL on your Ubuntu system! You can now use MySQL to create and manage databases.