centos7下yum 安装mysql5.7

系统 发表时间:2017-01-23 作者:赵七七 浏览次数:758


1.下载YUM库

wget http://dev.mysql.com/get/mysql57-community-release-el7-7.noarch.rpm

2.安装YUM库

 yum localinstall -y mysql57-community-release-el7-7.noarch.rpm

3.安装数据库

yum install -y mysql-community-server

4.启动MySQL服务

systemctl start mysqld.service

5.mysql -uroot -p

出现如下问题:

ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)

解决办法:

vim /etc/my.cnf在[mysqld]下边加入

skip-grant-tables

skip-networking

保存退出,重启mysql(systemctl restart mysqld.service)

输入mysql -uroot -p 就愉快的进去了

6.重置root密码后重启mysql服务

update mysql.user set authentication_string=password("yourpassword") where user="root" and Host="localhost";

flush privileges;

quit;

7.vim /etc/my.cnf 将加入的两行去掉(很重要要不mysql就能不用密码访问了)

8.mysql -uroot -pyourpassword

然后你进去了

show databases;

然后如果正常运行往下的就可以忽略一下的

我的报错:

ERROR 1820 (HY000): You must SET PASSWORD before executing this statement

然后我就按照他的要求重置密码:SET PASSWORD = PASSWORD('123456');

本以为就这么结束了,但是接着又来一报错,也是够可以了

Your password does not satisfy the current policy requir(密码不符合当前规范)

现在就有两种办法了:

1.官网给出的解决办法:

http://dev.mysql.com/doc/refman/5.7/en/validate-password-plugin.html

 ALTER USER 'jeffrey'@'localhost'

    -> IDENTIFIED WITH mysql_native_password

    -> AS '*0D3CED9BEC10A777AEC23CCC353A8C08A633045E';

    就是把密码设置复杂点,满足validate_password插件的要求

2.禁用validate_password插件

vim my.cnf

在[mysqld]后边加上

validate_password=off


然后你就可以随意的修改密码之类的到此mysql安装成功