CentOS is a popular Linux operating system widely used in server environments. MySQL is a popular relational database management system. There are multiple ways to install MySQL on CentOS, the most common of which is using the yum package manager. This article will introduce in detail how to use yum to install MySQL.
Before installing any packages, it is a good idea to update the package cache. Use the following command:
sudo yum update
Use the following command to install MySQL:
sudo yum install mysql-server
After running this command, yum will automatically install mysql Services and their associated dependencies.
After the MySQL installation is completed, you need to start its service. Run the following command:
sudo systemctl start mysqld
This will start the MySQL service. If you want to automatically start the MySQL service when the system starts, please use the following command:
sudo systemctl enable mysqld
After installing MySQL, you need to configure it. Before using it, we need to run the following command to ensure that the MySQL service is up and running:
sudo systemctl status mysqld
Next, use the following command to configure MySQL:
sudo mysql_secure_installation
You will be prompted to set up the MySQL root The user's password, and select whether you want to make additional security settings during the MySQL installation.
Now, you have successfully installed and configured MySQL. Log in to MySQL using the following command:
mysql -u root -p
This will prompt you to enter the password for the MySQL root user. If the credentials are correct, you will be logged into the MySQL shell.
In some cases, you may need to access the MySQL server on a remote computer, at this time you need to install the MySQL client for remote connect. Install the MySQL client using the following command:
sudo yum install mysql
Once the installation is complete, you can connect to the remote server using the following command:
mysql -h <remote-server-ip> -u <username> -p
replacee16fe5fb652a707102b0e883ba31817d
and d6025a37ea8687b5422f951f7288bdc5
are the IP address and username of the MySQL server you want to connect to.
Conclusion
Using the yum package manager to install MySQL on CentOS is a very easy and fast way. After installation, ensure that MySQL is always configured and security set up to ensure data safety and security.
The above is the detailed content of centos yum install mysql. For more information, please follow other related articles on the PHP Chinese website!