MySQL is a popular relational database management system that is widely used in Linux systems. In this article, we will explain how to install MySQL on a Linux system.
Step 1: Uninstall the old version of MySQL
If you have installed the old version of MySQL, you need to uninstall it first. You can use the following command to uninstall MySQL:
sudo apt-get remove --purge mysql-server mysql-client mysql-common sudo apt-get autoremove sudo apt-get autoclean
Step 2: Update the package list
Before installing MySQL, we need to update the package list first. You can use the following command to update the package list:
sudo apt-get update
Step 3: Install MySQL
Install MySQL You can use the following command:
sudo apt-get install mysql-server
During the installation process, the system will ask You set the MySQL root user password. After setting the password, MySQL will automatically run and be enabled.
Step 4: Check whether MySQL is running normally
You can use the following command to check whether MySQL is running normally:
sudo systemctl status mysql
If MySQL is running normally, you will see something similar to the following :
mysql.service - MySQL Community Server Loaded: loaded (/lib/systemd/system/mysql.service; enabled; vendor preset: enabled) Active: active (running) since Tue 2019-09-10 11:06:22 CST; 1h 1min ago
Step Five: Connect to MySQL
You can use the following command to connect to MySQL:
mysql -u root -p
When prompted for the password, enter the password you set in step three password.
Now you have successfully connected to the MySQL database server.
Conclusion
Through the above steps, you have successfully installed and configured MySQL on your Linux system. MySQL is a powerful database management system with which various database tasks can be easily handled.
The above is the detailed content of How to install MySQL on Linux systems. For more information, please follow other related articles on the PHP Chinese website!