admin

centos yum安装mysql8.0

admin 数据库 2020-03-18 1794浏览 0

yum安装

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

--------------------- 


配置文件

vim /etc/my.cnf

#修改或添加skip-grant-tables跳过密码

skip-grant-tables


添加用户

#重启mysql服务:  

service mysqld restart


#将旧密码置空

mysql -u root -p    //提示输入密码时直接敲回车。


#选择数据库

use mysql


#将密码置空

update user set authentication_string = '' where user = 'root';


#退出

quit


#去除免密码登陆


#删掉步骤1的语句  skip-grant-tables


#重启服务  service mysqld restart


#修改密码


mysql -u root -p  //提示输入密码时直接敲回车,刚刚已经将密码置空了


#密码形式过于简单则会报错

ALTER USER 'root'@'localhost' IDENTIFIED BY 'yourpassword' -----------------



授权


mysql8.0无法给用户授权或提示You are not allowed to create a user with GRANT的问题

提示意思是不能用grant创建用户,mysql8.0以前的版本可以使用grant在授权的时候隐式的创建用户,8.0以后已经不支持,所以必须先创建用户,然后再授权,命令如下:

mysql> CREATE USER 'root'@'%' IDENTIFIED BY 'Hadoop3!';
Query OK, 0 rows affected (0.04 sec)

mysql> grant all privileges on *.* to 'root'@'%';
Query OK, 0 rows affected (0.03 sec)

另外,如果远程连接的时候报plugin caching_sha2_password could not be loaded这个错误,可以尝试修改密码加密插件:

 mysql> alter user 'root'@'%' identified with mysql_native_password by 'Hadoop3!';


版权声明

本站《作品展示》类文章均为原创,转载必须注明出处,技术分享类文章部分来源于网络,版权归原作者所有,若侵权请留言。

发表评论