Rumah > Artikel > pangkalan data > linux源码安装mysql5.7
1. 下载mysql源安装包
wget http://dev.mysql.com/get/mysql57-community-release-el7-8.noarch.rpm
2. 安装mysql源
yum localinstall mysql57-community-release-el7-8.noarch.rpm
3. 检查mysql源是否安装成功
yum repolist enabled | grep "mysql.*-community.*"
4.看到上图表示安装成功
可以修改vim /etc/yum.repos.d/mysql-community.repo源,改变默认安装的mysql版本。比如要 安装5.6版本,将5.7源的enabled=1改成enabled=0。然后再将5.6源的enabled=0改成enabled=1即可。改完之后的效果如下所示:
5.安装Mysql
yum install mysql-community-server
6.启动Mysql
systemctl start mysqld
7.开机启动
systemctl enable mysqldsystemctl daemon-reload
8.修改root本地登录密码
mysql安装完成之后,在/var/log/mysqld.log文件中给root生成了一个默认密码。通过下面的方式找到root默认密码,然后登录mysql进行修改:
grep 'temporary password' /var/log/mysqld.log
命令:
mysql -uroot -p
问题:centos7.0安装完mysql5.7.11之后使用mysql -u root -p 连接数据库。操作提示:You must reset your password using ALTER USER statement before executing this statement.
按照提示ALTER USER 修改密码无效,后来发现执行如下命令即可:
SET PASSWORD = PASSWORD(‘123456’); set password for 'root'@'localhost'=password('你的新密码');
默认密码检查策略要求密码必须包含:大小写字母、数字和特殊符号,并且长度不能少于8位。否则会提示ERROR 1819 (HY000): Your password does not satisfy the current policy requirements错误,如下图所示:
grant all on *.* to 'root'@'127.0.0.1' identified by '123123'WITH GRANT OPTION; flush privileges; //刷新权限表
注意事项:
修改配置后要重新启动mysql服务生效:
systemctl restart mysqld
默认配置文件路径:
配置文件:/etc/my.cnf
日志文件:/var/log//var/log/mysqld.log
服务启动脚本:/usr/lib/systemd/system/mysqld.service
socket文件:/var/run/mysqld/mysqld.pid
Atas ialah kandungan terperinci linux源码安装mysql5.7. Untuk maklumat lanjut, sila ikut artikel berkaitan lain di laman web China PHP!