centos7安装mysql5.7
centos7安装mysql5.7
一、配置YUM源
-
在MySQL官网中下载YUM源rpm安装包:https://dev.mysql.com/downloads/repo/yum/
- 下载mysql源安装包
wget https://dev.mysql.com/get/mysql57-community-release-el7-8.noarch.rpm
-
安装mysql源
yum localinstall mysql57-community-release-el7-8.noarch.rpm
-
检查mysql源是否安装成功
yum repolist enabled | grep "mysql.*-community.*"
可以修改vim /etc/yum.repos.d/mysql-community.repo源,改变默认安装的mysql版本。 比如要安装5.6版本,将5.7源的enabled=1改成enabled=0。然后再将5.6源的enabled=0改成enabled=1即可。
二、安装mysql
yum install mysql-community-server
三、启动mysql服务
systemctl start mysqld
四、修改密码
-
登录
mysql -u root -p
-
初始密码
grep 'temporary password' /var/log/mysqld.log
-
进入mysql后,设置密码
mysql>set password for 'root'@'localhost'=password('密码');
或
mysql>ALTER USER 'root'@'localhost' IDENTIFIED BY '密码';
参考地址