# 开启MySQL远程访问权限 允许远程连接

> 来源：梦飞idc云平台 | 原文：https://www.mfisp.com/10582.html | 发布：2022-09-27 | 更新：2022-09-27 | 分类：建站教程、投稿分享

## 系统环境：Linux CentOS 数据库版本：MySQL5.7

 

### 1、登陆mysql数据库

 

mysql -h ip地址 -u 用户名 -p 密码

  

### 2、增加远程连接权限

 

```

```

 
 
1. use mysql; 
1. grant all privileges on *.* to 远程连接用户名@'%' identified by "远程连接密码"; 
1. flush privileges; 

 

```

```

 

### 3.修改MySQL配置文件

 

```
vim /etc/mysql/mysql.conf.d/mysqld.cnf
```

 

注释掉`bind-address`这行

 

### 4.重启数据库

 

```

```

 
 
1. service mysql restart 
1. 或(选择一个可以运行的命令进行尝试) 
1. systemctl restart mysqld 

 

```

```

 

### 5.如果想要修改数据密码怎么办呢？可以使用以下命令进行操作

 

```

```

 

#进入数据库  
use mysql;  
   
#修改密码  
update mysql.user set authentication_string=password('new password') where user='root';  
   
#刷新使其生效  
flush privileges;

 

![开启MySQL远程访问权限 允许远程连接](https://www.mfisp.com/wp-content/uploads/2021/12/13281957246015c_1_post.jpg)

---
本页由 梦飞idc云平台（https://www.mfisp.com）提供。站点导航见 https://www.mfisp.com/llms.txt
