CentOS(linux) 下MySQL8.0.11的yum安装

CentOS(linux) 下MySQL8.0.11的安装


系统
CentOS 7.4
安装软件
MySQL8.0.11


wget https://dev.mysql.com/get/mysql80-community-release-el7-1.noarch.rpm
  • 安装yum源
yum localinstall mysql80-community-release-el7-1.noarch.rpm
  • 更新yum源
yum clean all
yum makecache
  • 创建Mysql账户
groupadd mysql
useradd -g mysql mysql
  • 开始安装MySQL
yum install mysql-community-server
  • 启动MySQL
systemctl  start  mysqld
  • 查看初始化密码
cat /var/log/mysqld.log | grep password

CentOS(linux) 下MySQL8.0.11的yum安装

  • 登录MySQL
mysql -u root -p
  • 修改初始化密码(密码一定要大小写字母+数字+符号,如:Aa-123456789)
ALTER USER 'root'@'localhost' IDENTIFIED BY 'yourpassword';
  • 远程设置
use mysql;
update user set host='%' where user='root';
  • 允许任何主机访问数据库
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%'WITH GRANT OPTION;
FLUSH PRIVILEGES;
  • 允许myuser用户使用mypassword密码从任何主机连接到mysql服务器
GRANT ALL PRIVILEGES ON *.* TO 'myuser'@'%'IDENTIFIED BY 'mypassword' WITH GRANT OPTION;
  • 允许用户myuser从ip为192.168.1.6的主机连接到mysql服务器,并使用mypassword作为密码
GRANT ALL PRIVILEGES ON *.* TO 'myuser'@'192.168.1.3'IDENTIFIED BY 'mypassword' WITH GRANT OPTION;

报错备注

ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)

解决:/etc/my.cnf 下[mysqld]后添加 skip-grant-tables

ERROR 1290 (HY000): The MySQL server is running with the --skip-grant-tables option so it cannot execute this statement

解决:刷新权限:flush privileges;

参考文献:CentOS7 安装 mysql8

相关推荐