远程连接MariaDB数据库

1. 连接数据库
2. 授权并刷新权限
grant all privileges on *.* to 'root'@'%' identified by 'password' with grant option;
flush privileges;
3. 查看用户数据

use mysql
select user, password, host from user;
4.修改配置文件,注释bind-address

配置文件地址:/etc/mysql/mariadb.conf.d/50-server.cnf

mysql 数据库的配置文件:/etc/mysql/mysql.conf.d/mysqld.cnf

5.重启数据库

sudo systemctl restart mysql

另外一种方法:适用于mysql

1
2
3
4
5
6
7
8
9
10
11
12
13
mysql> use mysql
Database changed
mysql> select user,host from user;
+------------------+-----------+
| user             | host      |
+------------------+-----------+
| debian-sys-maint | localhost |
| mysql.infoschema | localhost |
| mysql.session    | localhost |
| mysql.sys        | localhost |
| root             | localhost |
+------------------+-----------+
5 rows in set (0.00 sec)

更改“mysql” 数据库里的 “user” 表里的 “host” 项,从“localhost”改称“%“

1
update user set host="%" where user = "root";
1
2
3
4
5
6
7
8
9
10
11
mysql> select user,host from user;
+------------------+-----------+
| user             | host      |
+------------------+-----------+
| root             | %         |
| debian-sys-maint | localhost |
| mysql.infoschema | localhost |
| mysql.session    | localhost |
| mysql.sys        | localhost |
+------------------+-----------+
5 rows in set (0.00 sec)

 

1
flush privileges;

  

 

posted @   华小电  阅读(389)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 阿里最新开源QwQ-32B,效果媲美deepseek-r1满血版,部署成本又又又降低了!
· SQL Server 2025 AI相关能力初探
· AI编程工具终极对决:字节Trae VS Cursor,谁才是开发者新宠?
· 开源Multi-agent AI智能体框架aevatar.ai,欢迎大家贡献代码
· Manus重磅发布:全球首款通用AI代理技术深度解析与实战指南
点击右上角即可分享
微信分享提示