加入收藏 | 设为首页 | 会员中心 | 我要投稿 南平站长网 (https://www.0599zz.com/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 站长学院 > MySql教程 > 正文

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

发布时间:2022-01-13 21:44:51 所属栏目:MySql教程 来源:互联网
导读:本篇文章给大家分享的是有关MySQL MariaDB密码以及远程访问权限配置是怎样的,小编觉得挺实用的,因此分享给大家学习,希望大家阅读完这篇文章后可以有所收获,话不多说,跟着小编一起来看看吧。 环境 MySQL 版本 Server version: 5.5.64-MariaDB MariaDB
      本篇文章给大家分享的是有关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密码以及远程访问权限配置是怎样的,小编相信有部分知识点可能是我们日常工作会见到或用到的。希望你能通过这篇文章学到更多知识。

(编辑:南平站长网)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    热点阅读