标签:centos7.3 安装mysql5.7并修改初始密码
http://dev.mysql.com/doc/mysql-yum-repo-quick-guide/en/
http://dev.mysql.com/downloads/repo/yum/
下载到本地再上传到服务器,或者使用wget 直接下载
wget http://repo.mysql.com/mysql57-community-release-el7-10.noarch.rpm
将platform-and-version-specific-package-name
替换为你下载的rpm名
sudo rpm -Uvh platform-and-version-specific-package-name.rpm
例如
rpm -Uvh mysql57-community-release-el7-10.noarch.rpm
yum install -y mysql-community-server
如果网络环境不是很好,执行完命令就可以去泡杯茶或者荣耀杀一局
service mysqld start
systemctl start mysqld.service
service mysqld status
systemctl status mysqld.service
Mysql5.7默认安装之后root是有密码的。
为了加强安全性,MySQL5.7为root用户随机生成了一个密码,在error log中,关于error log的位置,如果安装的是RPM包,则默认是/var/log/mysqld.log。
只有启动过一次mysql才可以查看临时密码
grep ‘temporary password‘ /var/log/mysqld.log
这里的密码是YdsGaxOq>2n!
使用默认的密码登陆
mysql -uroot -p
用该密码登录到服务端后,必须马上修改密码,不然会报如下错误:
mysql> select @@log_error; ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement. mysql>
修改密码
ALTER USER ‘root‘@‘localhost‘ IDENTIFIED BY ‘root123‘;
如果密码设置太简单出现以下的提示
如何解决ERROR 1819 (HY000): Your password does not satisfy the current policy requirements
呢? 这里直接提供解决方案文末有详细的说明
必须修改两个全局参数:
首先,修改validate_password_policy参数的值
mysql> set global validate_password_policy=0;
再修改密码的长度
set global validate_password_length=1;
再次执行修改密码就可以了
ALTER USER ‘root‘@‘localhost‘ IDENTIFIED BY ‘root123‘;
GRANT ALL PRIVILEGES ON *.* TO ‘root‘@‘%‘ IDENTIFIED BY ‘mypassword‘ WITH GRANT OPTION;FLUSH PRIVILEGES;
ERROR 1819 (HY000): Your password does not sa
标签:centos7.3 安装mysql5.7并修改初始密码
原文地址:http://262597308.blog.51cto.com/2871404/1941789