标签:下载页面 更改 允许 ring 随机 with mysql 访问 sha
进入mysql官网
选择mysql的官方yum源
选择对应的linux系统版本,点击download,进入下载页面
可以直接下载,也可以选择复制链接
复制链接后,可以在linux系统通过wget 上面复制的链接来下载,如wget https://dev.mysql.com/get/mysql80-community-release-el7-3.noarch.rpm,这样下载到文件mysql80-community-release-el7-3.noarch.rpm,然后通过通过rpm -ivh mysql80-community-release-el7-3.noarch.rpm 来安装mysql的yum源或者通过yum install -y mysql80-community-release-el7-3.noarch.rpm 来安装mysql的yum源,也可以跳过下载,使用yum直接在线安装mysql的yum源,如yum install -y https://dev.mysql.com/get/mysql80-community-release-el7-3.noarch.rpm
安装好yum源后,可以到/etc/yum.repos.d查看安装的mysql yum源文件.repo
打开 mysql-community.repo,可以看到mysql 8.0是默认生效的,也就是会默认安装mysql8.0版本,如果想安装5.7等版本,只需让5.7生效,其他版本失效即可。
更新yum缓存
yum makecache
可以查看一下yum上的mysql相关资源
安装社区版mysql服务器
yum install -y mysql-community-server
安装完成以后,启动mysql
systemctl start mysqld,第一次启动时会初始化mysql配置
设置开启随机启动
systemctl enable mysqld
mysql安装的目录在 /var/lib/mysql
配置文件为/etc/my.cnf
启动日志文件为 /var/log/mysqld.log,这里有初始化的临时密码
登录mysql
[root@localhost log]# mysql -uroot -p Enter password: //这里输入日志里的临时密码,回车,进入mysql mysql> set global validate_password_policy=0; ERROR 1193 (HY000): Unknown system variable ‘validate_password_policy‘ mysql> set global validate_password.policy=0; Query OK, 0 rows affected (0.01 sec) mysql> set global validate_password.length=1; Query OK, 0 rows affected (0.00 sec) mysql> ALTER USER ‘root‘@‘localhost‘ IDENTIFIED BY ‘123456‘; Query OK, 0 rows affected (0.01 sec)
---------------------------------------------------
解释:下面两行命令,是为了可以设置简单形式的密码
set global validate_password.policy=0;
set global validate_password.length=1;
然后将密码改为123456:ALTER USER ‘root‘@‘localhost‘ IDENTIFIED BY ‘123456‘;
如果是5.7版的mysql,命令则是:
mysql> set global validate_password_policy=0;
mysql> set global validate_password_length=1;
-----------------------------------------------------
查看root用户的加密方式和被允许登录的主机
mysql> select user, host, plugin, authentication_string from user\G;
*************************** 1. row ***************************
user: mysql.infoschema
host: localhost
plugin: caching_sha2_password
authentication_string: $A$005$THISISACOMBINATIONOFINVALIDSALTANDPASSWORDTHATMUSTNEVERBRBEUSED
*************************** 2. row ***************************
user: mysql.session
host: localhost
plugin: caching_sha2_password
authentication_string: $A$005$THISISACOMBINATIONOFINVALIDSALTANDPASSWORDTHATMUSTNEVERBRBEUSED
*************************** 3. row ***************************
user: mysql.sys
host: localhost
plugin: caching_sha2_password
authentication_string: $A$005$THISISACOMBINATIONOFINVALIDSALTANDPASSWORDTHATMUSTNEVERBRBEUSED
*************************** 4. row ***************************
user: root
host: localhost
plugin: caching_sha2_password
authentication_string: *6BB4837EB74329105EE4568DDA7DC67ED2CA2AD9
解释:
host: localhost #只允许本机登录root,如果原创要访问,需要开启远程访问才行
plugin: caching_sha2_password #8.0版本新的加密方式,navicat客户端不支持这种方式,如果远程用navicat客户端连接,需要修改会老版本的加密方式
开启root用户可以远程访问操作
#更改加密方式:
mysql> ALTER USER ‘root‘@‘localhost‘ IDENTIFIED BY ‘password‘ PASSWORD EXPIRE NEVER;
Query OK, 0 rows affected (0.01 sec)
#更改root密码
mysql> ALTER USER ‘root‘@‘localhost‘ IDENTIFIED WITH mysql_native_password BY ‘123456‘;
Query OK, 0 rows affected (0.17 sec)
#开启root被远程访问
mysql> update user set host = ‘%‘ where user = ‘root‘;
Query OK, 1 row affected (0.09 sec)
Rows matched: 1 Changed: 1 Warnings: 0
#刷新
mysql> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.00 sec)
#查看数据库中的各账号信息,可以看到root用户允许任意主机访问%,且加密方式和老版本的一样用 mysql_native_password
mysql> select user, host, plugin, authentication_string from user;
+------------------+-----------+-----------------------+------------------------------------------------------------------------+
| user | host | plugin | authentication_string |
+------------------+-----------+-----------------------+------------------------------------------------------------------------+
| root | % | mysql_native_password | *6BB4837EB74329105EE4568DDA7DC67ED2CA2AD9 |
| mysql.infoschema | localhost | caching_sha2_password | $A$005$THISISACOMBINATIONOFINVALIDSALTANDPASSWORDTHATMUSTNEVERBRBEUSED |
| mysql.session | localhost | caching_sha2_password | $A$005$THISISACOMBINATIONOFINVALIDSALTANDPASSWORDTHATMUSTNEVERBRBEUSED |
| mysql.sys | localhost | caching_sha2_password | $A$005$THISISACOMBINATIONOFINVALIDSALTANDPASSWORDTHATMUSTNEVERBRBEUSED |
+------------------+-----------+-----------------------+------------------------------------------------------------------------+
4 rows in set (0.00 sec)
标签:下载页面 更改 允许 ring 随机 with mysql 访问 sha
原文地址:https://www.cnblogs.com/tyhj-zxp/p/12706986.html