通过IP远程连接MySQL服务时不允许连接到这个MySQL服务器

当你在连接Mysql时报这个错误时

is not allowed to connect to this MySQL server,意思是 MySQL 服务器不允许来自 IP 地址的连接。这通常是由于 MySQL 服务器的访问控制列表(ACL)限制了特定主机的连接。

要解决这个问题,你需要授予该主机连接到 MySQL 服务器的权限。以下是具体步骤:

  1. 以具有管理权限的用户身份登录 MySQL 服务器(通常是 root 用户)。
  2. 授予必要的权限 给该主机。你可以通过运行以下 SQL 命令来实现:
c 复制代码
GRANT ALL PRIVILEGES ON *.* TO 'your_username'@'192.168.16.180' IDENTIFIED BY 'your_password';

将 'your_username' 替换为你想要授予权限的用户名,将 'your_password' 替换为该用户的密码。

  1. 刷新权限 以应用更改:
c 复制代码
FLUSH PRIVILEGES;

我这里通过命令行连接到 MySQL 服务器

  1. 输入密码:
    输入密码,如果你的用户没有密码,按回车键。
  2. 验证连接:
    一旦成功连接,你会看到 MySQL 的命令提示符。
c 复制代码
PS D:\> D:\ProgramData\mysql\mysql-5.6.50-winx64\bin.\mysql -u root -p''
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 6
Server version: 5.6.50 MySQL Community Server (GPL)

Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

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

你就可以在 MySQL 命令提示符下执行 SQL 命令了。(OK就是成功了)

c 复制代码
mysql> GRANT ALL PRIVILEGES ON *.* TO 'root'@'192.168.....' IDENTIFIED BY '';
Query OK, 0 rows affected (0.00 sec)

mysql> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.00 sec)
相关推荐
勤奋的凯尔森同学17 分钟前
webmin配置终端显示样式,模仿UbuntuDesktop终端
linux·运维·服务器·ubuntu·webmin
月光水岸New42 分钟前
Ubuntu 中建的mysql数据库使用Navicat for MySQL连接不上
数据库·mysql·ubuntu
狄加山67543 分钟前
数据库基础1
数据库
我爱松子鱼1 小时前
mysql之规则优化器RBO
数据库·mysql
丁卯4041 小时前
Go语言中使用viper绑定结构体和yaml文件信息时,标签的使用
服务器·后端·golang
chengooooooo1 小时前
苍穹外卖day8 地址上传 用户下单 订单支付
java·服务器·数据库
Rverdoser2 小时前
【SQL】多表查询案例
数据库·sql
Galeoto2 小时前
how to export a table in sqlite, and import into another
数据库·sqlite
人间打气筒(Ada)3 小时前
MySQL主从架构
服务器·数据库·mysql
leegong231113 小时前
学习PostgreSQL专家认证
数据库·学习·postgresql