温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

MySQL MariaDB密码以及远程访问权限配置是怎样的

发布时间:2021-10-08 15:54:38 来源:亿速云 阅读:138 作者:柒染 栏目:MySQL数据库

本篇文章给大家分享的是有关MySQL  MariaDB密码以及远程访问权限配置是怎样的,小编觉得挺实用的,因此分享给大家学习,希望大家阅读完这篇文章后可以有所收获,话不多说,跟着小编一起来看看吧。

环境
MySQL 版本 Server version: 5.5.64-MariaDB MariaDB Server
Linux版本  CentOS Linux release 7.6.1810 (AltArch)


操作
1)root默认情况下无须密码登陆,直接回车,要求输入密码,直接回车
root@host-172-16-61-102 bin]# mysql -uroot -p
PASSWORD:
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 35
Server version: 5.5.64-MariaDB MariaDB Server

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

2)选择数据库,否则执行指令出错No database selected
MariaDB [(none)]> use mysql
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed

3)指定root用户的密码是root
MariaDB [mysql]> update user set password=password("root")where user='root';
Query OK, 0 rows affected (0.00 sec)
Rows matched: 5  Changed: 0  Warnings: 0
注意:
执行无效情况下,可能是版本的问题,查看是否是password字段还是authentication_string字段保存密码
update user set password = password("root"),authentication_string=password("root") where user=root;
通过指令desc user 可以查看当前user的表结构


4)授予访问权限
root用户使用密码从任何主机连接到mysql服务器
MariaDB [mysql]> GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'root' WITH GRANT OPTION;
其中BY后面是root用户的密码:root

只允许192.168.10.168通过root用户连接到mysql服务器
GRANT ALL PRIVILEGES ON *.* TO 'root'@'192.168.10.168' IDENTIFIED BY 'root' WITH GRANT OPTION;

5)刷新权限
MariaDB [mysql]> flush privileges;
Query OK, 0 rows affected (0.00 sec)


注意:
1)Navicat远程登陆失败
1045 - Access denied for user 'root@192.168.63.184' (using password: YES)
授予访问权限没有执行,执行第四步
可通过指令 select host,user from user;查看是否有远程访问的权限
2)关闭防火墙
systemctl stop firewalld.service            #停止firewall
systemctl disable firewalld.service        #禁止firewall开机启动
开启端口
firewall-cmd --zone=public --add-port=3306/tcp --permanent
mysql服务启动,可以通过lsof -i:3306端口是否监听
重启防火墙
firewall-cmd --reload

以上就是MySQL  MariaDB密码以及远程访问权限配置是怎样的,小编相信有部分知识点可能是我们日常工作会见到或用到的。希望你能通过这篇文章学到更多知识。更多详情敬请关注亿速云行业资讯频道。

向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI