安装环境
centos 7.7.1908
1. 标题获取rpm源
官方全的rpm源
本次安装centos7系统使用 https://repo.mysql.com//mysql80-community-release-el7-3.noarch.rpm
wget https://repo.mysql.com//mysql80-community-release-el7-3.noarch.rpm
2. 安装Mysql8,安装其他版本请参考官方文档
速度不怎么快,稍安勿躁
yum install -y mysql-community-server
3. 启动服务及验证
sudo systemctl start mysqld.service # 启动
sudo systemctl status mysqld.service # 查看状态
4. 重置密码
sudo grep 'temporary password' /var/log/mysqld.log # 查看密码
mysql -u root -p # 登陆
ALTER USER 'root'@'localhost' IDENTIFIED BY 'MyNewPass4!'; # 重置密码,密码最少8位,包含大写小写数字特殊字符
5. 远程登录
CREATE USER 'root'@'%' IDENTIFIED BY 'RemotePass'; # 远程登录密码,跟本地登陆区分开增强安全性
# 可以通过mysql指令查到
use mysql;
show user, host from user;
# +------------------+-----------+
# | user | host |
# +------------------+-----------+
# | root | % | 有这项就能远程登录了
# | mysql.infoschema | localhost |
# | mysql.session | localhost |
# | mysql.sys | localhost |
# | root | localhost |
# +------------------+-----------+
6. 创建schema权限问题
select user,host,Grant_priv,super_priv from user;
# +------------------+-----------+------------+------------+
# | user | host | Grant_priv | super_priv |
# +------------------+-----------+------------+------------+
# | root | % | N | N |
# | mysql.infoschema | localhost | N | N |
# | mysql.session | localhost | N | Y |
# | mysql.sys | localhost | N | N |
# | root | localhost | Y | Y |
# +------------------+-----------+------------+------------+
发现权限不够,需要设置一下权限
update user set grant_priv='Y', super_priv='Y' where user='root';
flush privileges;
grant all on *.* to 'root'@'%';
权限不够的时候执行上述命令,不过一定要 重新登陆 才能生效~
完~