重庆分公司,新征程启航

为企业提供网站建设、域名注册、服务器等服务

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

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

成都创新互联公司主要从事网站建设、成都网站设计、网页设计、企业做网站、公司建网站等业务。立足成都服务鱼台,十年网站建设经验,价格优惠、服务专业,欢迎来电咨询建站服务:13518219792

环境
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密码以及远程访问权限配置是怎样的,小编相信有部分知识点可能是我们日常工作会见到或用到的。希望你能通过这篇文章学到更多知识。更多详情敬请关注创新互联行业资讯频道。


文章标题:MySQLMariaDB密码以及远程访问权限配置是怎样的
网站地址:http://cqcxhl.cn/article/jpspdj.html

其他资讯

在线咨询
服务热线
服务热线:028-86922220
TOP