安装mysql8.0.17并配置远程访问的⽅法
⼀、安装前准备
查看数据库版本命令:mysql --version
mysql-community-common-8.0.17-1.el7.x86_64.rpm
mysql-community-libs-8.0.17-1.el7.x86_64.rpm
mysql-community-client-8.0.17-1.el7.x86_64.rpm
mysql-community-server-8.0.17-1.el7.x86_64.rpm
⼆、安装RPM包
依次安装上述RPM包,前后安装包为依赖关系。
# rpm -ivh mysql-community-common-8.0.17-1.el7.x86_64.rpm
# rpm -ivh mysql-community-libs-8.0.17-1.el7.x86_64.rpm
# rpm -ivh mysql-community-client-8.0.17-1.el7.x86_64.rpm
# rpm -ivh mysql-community-server-8.0.17-1.el7.x86_64.rpm
三、查询root账户初始密码
mysql 8.0版本的初始密码默认⾮空,安装时⾃动⽣成,存储在/var/log/mysqld.logzhon中。
# rpm -ivh mysql-community-common-8.0.17-1.el7.x86_64.rpm
# rpm -ivh mysql-community-libs-8.0.17-1.el7.x86_64.rpm
# rpm -ivh mysql-community-client-8.0.17-1.el7.x86_64.rpm
# rpm -ivh mysql-community-server-8.0.17-1.el7.x86_64.rpm
四、修改root密码
修改密码默认有安全性要求,对密码复杂度有控制。
mysql> alter user 'root'@'localhost' identified by 'redhat';
ERROR 1819 (HY000): Your password does not satisfy the current policy requirements
mysql> alter user 'root'@'localhost' identified by '1qaz!QAZ';
Query OK, 0 rows affected (0.15 sec)
mysql> flush privileges;
Query OK, 0 rows affected (0.01 sec)
五、查看当前⽤户配置信息
root的初始密码mysql> show databases;
mysql> use mysql;
mysql> select user,host,plugin from user;
六、新建⼀⽤户⽤于远程访问
mysql> create user 'wangwang'@'%' identified by '1qaz!QAZ';
Query OK, 0 rows affected (0.08 sec)
mysql> grant all on *.* to 'wangwang'@'%';
Query OK, 0 rows affected (0.12 sec)
mysql> select user,host,plugin from user;
该账户的plugin加密⽅式为caching_sha2_password, MySQL 8.0前的客户端在连接 MySQL 8.0服务器时会出现Authentication plugin 'caching_sha2_password' cannot be loaded 的错误(需要更该为mysql_native_password)。
七、修改加密⽅式
修改加密规则
mysql> alter user 'wangwang'@'%' identified by '1qaz!QAZ' password expire never;
Query OK, 0 rows affected (0.17 sec)
更新⽤户密码
mysql> alter user 'wangwang'@'%' identified with mysql_native_password by '1qaz!QAZ';
Query OK, 0 rows affected (0.04 sec)
保存更改
mysql> flush privileges;
Query OK, 0 rows affected (0.05 sec)
查询信息
mysql> select user,host,plugin from user;
⼋、测试连接
可以使⽤Navicat进⾏测试。
总结
以上所述是⼩编给⼤家介绍的安装mysql 8.0.17并配置远程访问的⽅法,希望对⼤家有所帮助,如果⼤家有任何疑问请给我留⾔,⼩编会及时回复⼤家的。在此也⾮常感谢⼤家对⽹站的⽀持!
如果你觉得本⽂对你有帮助,欢迎转载,烦请注明出处,谢谢!
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。
发表评论