Home > Database > Mysql Tutorial > body text

centos yum install mysql

王林
Release: 2023-05-20 09:21:07
Original
697 people have browsed it

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.

  1. Update the package cache

Before installing any packages, it is a good idea to update the package cache. Use the following command:

sudo yum update
Copy after login
  1. Install MySQL

Use the following command to install MySQL:

sudo yum install mysql-server
Copy after login

After running this command, yum will automatically install mysql Services and their associated dependencies.

  1. Start the MySQL service

After the MySQL installation is completed, you need to start its service. Run the following command:

sudo systemctl start mysqld
Copy after login

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
Copy after login
  1. Configuring MySQL

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
Copy after login

Next, use the following command to configure MySQL:

sudo mysql_secure_installation
Copy after login

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.

  1. Login to MySQL

Now, you have successfully installed and configured MySQL. Log in to MySQL using the following command:

mysql -u root -p
Copy after login

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.

  1. Install MySQL client

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
Copy after login

Once the installation is complete, you can connect to the remote server using the following command:

mysql -h <remote-server-ip> -u <username> -p
Copy after login

replace<remote-server-ip> and <username> 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!

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template