CentOS7 default database is MARIADB, configuration and so on is not used to, so decided to change to MySQL, but the CentOS7 yum source default seems to be no MySQL. To solve this problem, we need to download the MySQL repo source first.
1. Download the MySQL repo source
$ wget http://repo.mysql.com/mysql-community-release-el7-5.noarch.rpm
2. Install the MYSQL-COMMUNITY-RELEASE-EL7-5.NOARCH.RPM package
$ sudo rpm-ivh mysql-community-release-el7-5.noarch.rpm
After installing this package, you will get two MySQL yum repo Source:/etc/yum.repos.d/mysql-community.repo,/etc/yum.repos.d/mysql-community-source.repo.
3. Install MySQL
$ sudo yum install Mysql-server
Follow the prompts to install, but there is no password after installation, you need to reset the password
4. Reset MySQL Password
$ mysql-u Root
This error may be reported at login: Error 2002 (HY000): Can ' t connect to local MySQL server through socket '/var/lib/mysql/mysql.sock ' (2) because/var /lib/mysql access rights issues. The following command changes the owner of the/var/lib/mysql to the current user:
$ sudo chown-r root:root/var/lib/mysql
Restart MySQL Service
$ Service Mysqld Restart
Next login to reset Password:
$ mysql-u root//Direct enter into MySQL console
mysql > Use MySQL;
MySQL > Update user set Password=password (' 123456 ') where user= ' root ';
MySQL > exit;
This article permanently updates the link address : http://www.linuxidc.com/Linux/2016-09/134940.htm
Installing MySQL with Yum under CentOS 7.0