CentOS 7 install MySQL server


discover problems

To install MySQL server in CentOS 6, you can use the command directlyyum -y install mysql-serverBut in CentOSNo package mysql-server available. Error: Nothing to doError. The detailed error information is as follows:

[[email protected] ~]# yum -y install mysql-server
Loaded plugins: fastestmirror
Repository base is listed more than once in the configuration
Repository updates is listed more than once in the configuration
Repository extras is listed more than once in the configuration
Repository centosplus is listed more than once in the configuration
Repository contrib is listed more than once in the configuration
Loading mirror speeds from cached hostfile
 * base: mirrors.cloud.aliyuncs.com
 * extras: mirrors.cloud.aliyuncs.com
 * updates: mirrors.cloud.aliyuncs.com
No package mysql-server available.
Error: Nothing to do


UseMariaDBReplaceMySQLJust order


Simply put, MariaDB is the fork of MySQL, and the relationship between them is just like the relationship between red hat and CentOS. From Mysql to Oracle Oracle, MySQL has been removed from the list of packages provided by RHEL and CentOS.

Install MySQL

1. Install MariaDB and MariaDB server packages

sudo yum -y install mariadb mariasb-client

2. Start the MySQL service

sudo systemctl start mariadb

3. Start the MariaDB service and make the MariaDB service start automatically every time it is started

sudo systemctl enable mariadb

4. Check the startup status

sudo systemctl status mariadb

5. Strengthen the safety of MariaDB installation

sudo mysql_secure_installation

This shell has the following functions:
-Set the password of the root account
-Do not log in to the root cluster
-Remove anonymous login
-Remove test database

6. Query version number

mysql -v

Login test

Type the following command and enter the password.

mysql -u root -h localhost -p