Mariadb设置允许远程链接

一. 修改数据表

1.进入 mariadb

mysql -u root -p

2.修改表

MariaDB [mysql]> GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'root';
Query OK, 0 rows affected (0.00 sec)
  • 第一个位置,为数据库, 第二个位置,为表,所以 *.*,表示可以访问任意数据的任意表
  • 'root'@'%', root表示远端登录使用的用户名,%表示允许任意ip登录,可将指定ip替换掉%, root%可以自定义
  • IDENTIFIED BY 'root' 这个root 是登录时的使用的密码,(方便记忆就用了root,生产环境一定要替换掉)

3.查看修改后

MariaDB [mysql]> SELECT host,user,password from user;
+-----------+------+-------------------------------------------+
| host      | user | password                                  |
+-----------+------+-------------------------------------------+
| localhost | root | *81F5E21E35407D884A6CD4A731AEBFB6AF209E1B |
| %         | root | *81F5E21E35407D884A6CD4A731AEBFB6AF209E1B |
+-----------+------+-------------------------------------------+
2 rows in set (0.00 sec)
  • | % | root | *81F5E21E35407D884A6CD4A731AEBFB6AF209E1B |表示修改成功

二. 修改配置文件

/etc/mysql/mariadb.conf.d/50-server.cnfbind-address = 127.0.0.1# 注释掉

三.重启服务

 systemctl restart mariadb.service

四.远程链接

mysql -u root -proot -h 192.168.199.240 -D mysql

Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 8
Server version: 10.1.34-MariaDB-0ubuntu0.18.04.1 Ubuntu 18.04

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

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

MariaDB [mysql]> 

搞定收工




posted on   剩余价值  阅读(1100)  评论(0编辑  收藏  举报

编辑推荐:
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 理解Rust引用及其生命周期标识(上)
· 浏览器原生「磁吸」效果!Anchor Positioning 锚点定位神器解析
· 没有源码,如何修改代码逻辑?
阅读排行:
· 全程不用写代码,我用AI程序员写了一个飞机大战
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· 记一次.NET内存居高不下排查解决与启示
· DeepSeek 开源周回顾「GitHub 热点速览」
· 白话解读 Dapr 1.15:你的「微服务管家」又秀新绝活了
历史上的今天:
2019-09-11 在Linux上使用mssql-conf工具配置SQL Server 2017
< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5

导航

统计

点击右上角即可分享
微信分享提示