centos7 安装Mysql8.0笔记

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
yum install mysql-community-server
  • 查看初始化密码
cat /var/log/mysqld.log | grep password
  • MYSQL 安全设置 需要使用使用上一步root密码登录, 
  • 接下来,为了安全,MySQL 会提示你重置 root 密码,移除其他用户账号,禁用 root 远程登录,移除 test 数据库,重新加载 privilege 表格等,你只需输入 y 继续执行即可
  • 如果报错  Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)最简单方法重启下服务器,系统会生成一个新mysql.sock文件, 参考: https://blog.csdn.net/HeatDeath/article/details/79065872
mysql_secure_installation -p
  • 登录MySQL
mysql -u root -p
  • 先创建用户(密码规则:mysql8.0以上密码策略限制必须要大小写加数字特殊符号)
  • 此处%是指允许该用户在任何电脑上登录, localhost指指允许本地登录  ip指允许指定ip登录
create user test@'%' identified  by 'Aa-123456';
  • 给用户授权
  • 参数: grant 权限 on 数据库.表名 to 用户名@登录主机
grant all privileges on *.* to test@'%' with grant option;
flush privileges;
  • 远程连接报错 Unable to load authentication plugin 'caching_sha2_password'.
  • 是因为mysql8使用的是caching_sha2_password加密规则,最简单的方法是修改远程连接用户的加密规则:
ALTER USER 'test'@'%' IDENTIFIED WITH mysql_native_password BY 'Aa-123456';

参考链接: https://segmentfault.com/a/1190000015634108

      https://blog.csdn.net/SZStudy/article/details/80561207

      https://blog.csdn.net/HeatDeath/article/details/79065872

原文地址:https://www.cnblogs.com/xtxtx/p/9805519.html