Centos 7 yum 安装 mysql5.7

来源:互联网 发布:整型数据的表示范围 编辑:程序博客网 时间:2024/06/03 20:34

1.下载YUM库

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

2.安装YUM库

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

3.安装数据库

shell > yum install -y mysql-community-server

4.启动MySQL服务

shell > systemctl start  mysqld.service

5.默认空密码

shell >  mysql -uroot -p

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

shell >  update mysql.user set authentication_string=password("yourpassword") where user="root" and Host="localhost"; 
shell >  flush privileges; 
shell >  quit; 
shell >  systemctl restart mysqld;

如果手贱或者不知道啥原因出现如下问题:

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

请修改my.cnf,添加skip-grant-tables和skip-networking:

shell >  vi /etc/my.cnfshell >  [mysqld]         skip-grant-tables         skip-networking

重启mysql,然后重复以上修改密码步骤即可,记得修改完后,去掉my.cnf添加的两行

0 0