项目访问mysql时报: Failed to obtain JDBC Connection...:Host ‘X‘is not allowed to connect to this MySQL ser
2023-09-11 14:17:06 时间
我是迁移项目后,项目访问数据库时报的这个异常。这个异常是数据库只允许localhost或127.0.0.1访问,不允许远程访问。我用的本机IP都不行。
报错:
解决办法:修改访问权限即可。
进入/usr/local/mysql
[root@DATASC-DB-01-new logs]# mysql -uroot -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 117
Server version: 5.7.28-log MySQL Community Server (GPL)
Copyright (c) 2000, 2019, 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> 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
mysql> select user,host from user;
+---------------+-----------+
| user | host |
+---------------+-----------+
| mysql.session | localhost |
| mysql.sys | localhost |
| root | localhost |
+---------------+-----------+
3 rows in set (0.00 sec)
mysql> update user set host = '%' where user = 'root';
Query OK, 1 row affected (0.10 sec)
Rows matched: 1 Changed: 1 Warnings: 0
mysql> select user,host from user;
+---------------+-----------+
| user | host |
+---------------+-----------+
| root | % |
| mysql.session | localhost |
| mysql.sys | localhost |
+---------------+-----------+
3 rows in set (0.00 sec)
mysql> flush privileges;
Query OK, 0 rows affected (0.01 sec)
mysql>
flush privileges是为了将权限更新操作刷新到内存中,而不用下次启动时生效。
相关文章
- mysql索引总结(4)-MySQL索引失效的几种情况
- MySQL存储过程详解 mysql 存储过程
- MySQL 异步复制、半同步复制、增强半同步复制(史上最全)
- mysql之数据库操作进阶(三)
- uthentication to host '10.0.1.33' for user 'root' using method 'mysql_native_password' failed with message: Access denied for user 'root'@'PCName' (using password: YES)
- MySQL数据库与Redis缓存双写一致性
- [转]MySQL实现分页查询
- MySQL启动报错: Failed to start LSB start and stop MySQL
- Brew 卸载MySql以及安装Mysql
- MySQL第四讲 MySql Undo日志 - 对聚簇索引进行CUD操作
- 【MySQL进阶-09】深入理解mysql执行的底层机制
- 【MySQL进阶-02】mysql的explain执行计划以及索引优化
- Linux安装MySQL(只针对这个8.0版本其他版本的MYSQL不知道是不是也可以用可以自己尝试)
- MySQL定义条件和处理程序
- mysql update select 从查询结果中更新数据
- 通过Navicat for MySQL远程连接的时候报错mysql 1130的解决方法
- 基于Java(SSH框架)+MySQL 实现(Web)公司通用门户(CMS)网站【100010223】
- linux 建立 MySQL 账号
- 转 mysql 存储过程初探
- python操作mysql数据库系列-操作MySql数据库(五)
- python操作mysql数据库系列-操作MySql数据库(三)
- MySQL数据库使用mysqldump导出数据详解
- mysql性能优化-慢查询分析、优化索引和配置
- Mysql 存储引擎中InnoDB与Myisam的主要区别
- 在centos中php 在连接mysql的时候,出现Can't connect to MySQL server on 'XXX' (13)
- ERROR 2002 (HY000): Can’t connect to local MySQL server through socket ‘/var mysql (转)
- Linux 安装和配置MySQL
- MySQL管理员须知的两大漏洞与修复方法
- 【MySQL】实验五 子查询
- 【MySql 】is not allowed to connect to this MySql server 无法访问远程MySQL数据库
- MySQL 教程(基础篇)第04话:mysqld 和 mysql 命令的区别