CentOS7.x uses yum to install Mysql5.6

First check if there is an installed MySQL

yum list installed | grep mysql

Delete if it exists:

yum remove software name

There is no mysql-sever file when mysql is installed normally in the yum source of CentOS 7, you need to download it from the official website 

# wget http://dev.mysql.com/get/mysql-community-release-el7-5.noarch.rpm

# rpm -ivh mysql-community-release-el7-5.noarch.rpm

# yum install mysql-community-server

Restart the mysql service after successful installation

 # service mysqld restart

The first installation of mysql is the root account without a password

How to set a password

 # mysql -u root

mysql > set password for 'root'@'localhost' = password('666');

mysql> exit

Get it!

After the installation of mysql, there are multiple users in the mysql.user table. It is recommended to clear other users except root to ensure security and unnecessary bugs.

mysql> delete from mysql.user where host != 'localhost' or name !='root';

mysql> exit

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324378208&siteId=291194637