【Linux】CentOS6上mysql5.7安装

1.下载安装yum源

根据系统下载yum源

https://dev.mysql.com/downloads/repo/yum/

rpm -ivh xxxxx.rpm

2.修改yum源

vim /etc/yum.repos.d/mysql-community.repo

enable想要下载的版本

3.安装mysql

yum install mysql-community-server

4.启动

配置里修改了以下datadir路径

vim /etc/my.cnf

启动服务

service mysqld start

查看root初始密码

grep 'temporary password' /var/log/mysqld.log

登录数据库

shell> mysql -uroot -p

此时使用会报错“You must reset your password using ALTER USER statement before executing this statement.” 

使用以下步骤设置新密码:

step 1: SET PASSWORD = PASSWORD('your new password');

step 2: ALTER USER 'root'@'localhost' PASSWORD EXPIRE NEVER;

step 3: flush privileges;

 设置完成后重新登录数据库

猜你喜欢

转载自www.cnblogs.com/momolei/p/9966274.html