CentOS 7.0yum install MySQL

CentOS 7.0yum install MySQL

1. Download the repo source of mysql

$ 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 sources: /etc/yum.repos.d/mysql-community.repo, /etc/yum.repos.d/mysql-community-source.repo.

3. Install mysql

$ sudo yum install mysql-server

You can install it according to the prompts, but there is no password after the installation is complete, you need to reset the password

4. Reset mysql password

$ mysql -u root

Note: This error may be reported when logging in: ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2), the reason is /var/lib/ mysql access rights problem.

5. The following command changes the owner of /var/lib/mysql to the current user:

$ sudo chown -R root:root /var/lib/mysql

6. Restart the mysql service

$ service mysqld restart

7. Next log in to reset the password:

$ mysql -u root //Enter mysql console directly
mysql > use mysql;
mysql > update user set password=password('123456') where user='root';
mysql > exit;

 

Guess you like

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