Centos7快速yum部署mysql8
一、yum仓库下载MySQL
yum -y install https://repo.mysql.com//mysql80-community-release-el7-1.noarch.rpm
二、yum安装MySQL
yum -y install mysql-community-server
报错:
warning: /var/cache/yum/x86_64/7/mysql80-community/packages/mysql-community-icu-data-files-8.0.29-1.el7.x86_64.rpm: Header V4 RSA/SHA256 Signature, key ID 3a79bd29: NOKEY
Retrieving key from file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql
The GPG keys listed for the "MySQL 8.0 Community Server" repository are already installed but they are not correct for this package.
Check that the correct key URLs are configured for this repository.
Failing package is: mysql-community-icu-data-files-8.0.29-1.el7.x86_64
GPG Keys are configured as: file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql
解决:
rpm --import https://repo.mysql.com/RPM-GPG-KEY-mysql-2022
或者
yum -y install mysql-community-server --nogpgcheck
三、启动MySQL服务
systemctl start mysqld
四、查找初始密码
# 查看初始密码(如无内容直接跳过)
grep 'temporary password' /var/log/mysqld.log
五、登录MySQL
# 如果没有初始密码,直接回车,然后输入命令 flush privileges
mysql -uroot -p'初始密码'
六、修改root登录密码
# 可以通过skip-grant-tables配置跳过输入密码登录MySQL,MySQL配置文件是/etc/my.cnf
# 切换到mysql库
alter user 'root'@'localhost' identified by '新密码';
七、配置外部访问
1、设置阿里云安全组规则入方向,支持MySQL端口3306可访问
2、服务端登录MySQL,use mysql;然后执行select user,host from user可查看用户及对应允许访问主机
3、然后执行update user set host = '%' where user ='root';允许任何外部可访问;再执行上一步查看权限
浙公网安备 33010602011771号