本文参考
以下正文
运行环境 centos7.5(1908)
下载yum仓库文件
mysql yumno thanks不太明显...
获取到下载链接
https://repo.mysql.com//mysql80-community-release-el7-3.noarch.rpm
下载
wget https://repo.mysql.com//mysql80-community-release-el7-3.noarch.rpm
安装 YUM Repo 文件
yum localinstall -y mysql80-community-release-el7-3.noarch.rpm
选择具体的版本
// 查看 YUM 仓库关于 MySQL 的所有仓库列表
# yum repolist all | grep mysql
// 只查看启用的
# yum repolist enabled | grep mysql
mysql-cluster-7.5-community/x86_64 MySQL Cluster 7.5 Community 禁用
mysql-cluster-7.5-community-source MySQL Cluster 7.5 Community - So 禁用
mysql-cluster-7.6-community/x86_64 MySQL Cluster 7.6 Community 禁用
mysql-cluster-7.6-community-source MySQL Cluster 7.6 Community - So 禁用
mysql-cluster-8.0-community/x86_64 MySQL Cluster 8.0 Community 禁用
mysql-cluster-8.0-community-source MySQL Cluster 8.0 Community - So 禁用
mysql-connectors-community/x86_64 MySQL Connectors Community 启用: 141
mysql-connectors-community-source MySQL Connectors Community - Sou 禁用
mysql-tools-community/x86_64 MySQL Tools Community 启用: 105
mysql-tools-community-source MySQL Tools Community - Source 禁用
mysql-tools-preview/x86_64 MySQL Tools Preview 禁用
mysql-tools-preview-source MySQL Tools Preview - Source 禁用
mysql55-community/x86_64 MySQL 5.5 Community Server 禁用
mysql55-community-source MySQL 5.5 Community Server - Sou 禁用
mysql56-community/x86_64 MySQL 5.6 Community Server 禁用
mysql56-community-source MySQL 5.6 Community Server - Sou 禁用
mysql57-community/x86_64 MySQL 5.7 Community Server 禁用
mysql57-community-source MySQL 5.7 Community Server - Sou 禁用
mysql80-community/x86_64 MySQL 8.0 Community Server 启用: 161
mysql80-community-source MySQL 8.0 Community Server - Sou 禁用
官网给设了个坎儿,百度半小时才解决(yum命令不熟悉),5.7版本是不可用的,执行如下命令来启动YUM源:
yum install -y yum-utils
yum-config-manager --enable mysql57-community
yum-config-manager --disable mysql80-community
安装
yum install -y mysql-community-server
管理 MySQL 服务
// 启动
# systemctl start mysqld.service
// 查看状态
# systemctl status mysqld.service
// 开机自启动
# systemctl enable mysqld.service
// 查看监听端口,默认 3306
# ss -natl |grep 3306
防火墙打开3306端口
firewall-cmd --permanent --add-port=3306/tcp
firewall-cmd --reload
firewall-cmd --list-all
获取生成的临时密码
grep "password" /var/log/mysqld.log
[root@mysql ~]# grep "password" /var/log/mysqld.log
2020-04-13T01:37:48.134502Z 1 [Note] A temporary password is generated for root@localhost: swtaTGo8W62
修改密码(密码太过简单会报错);并且设置远程访问
mysql -uroot -p
输入临时密码
#修改密码
mysql> ALTER USER USER() IDENTIFIED BY '12345678';
#设置远程访问
mysql>use mysql;
mysql>update user set host = '%' where user = 'root';
#刷新
mysql>flush privileges;
网友评论