---
title: "Connections could not be acquired from the underlying database"
author: "ware"
date: "2013-01-29T10:49:55Z"
tags: []
categories: ["数据库"]
slug: "connections-could-not-be-acquired-from-the-underlying-database"
draft: false
lastmod: "2013-01-29T10:49:55Z"
id: 1777564
url: "https://ware.iteye.com/blog/1777564"
---

"Connections could not be acquired from the underlying database" 大概意思是说:不能连接当前所配置的数据库.

出现这种问题,一般是配置参数有误.若连接mysql数据库的话,这时还要考虑你设置远程mysql.否则,也会出这个问题.

远程访问MySQL的设置  
1.在User表中添加允许远程访问的用户  
insert into mysql.user(Host,User,Password,Select\_priv,Insert\_priv,Update\_priv,Delete\_priv,Create\_priv,  
Drop\_priv,Reload\_priv,Shutdown\_priv,Process\_priv,File\_priv,Grant\_priv,  
References\_priv,Index\_priv,Alter\_priv)  
values ('url', 'username', 'password', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y','Y', 'Y');  
然后重启mysql.

注意: 如果没有指定的固定IP地址，对应的Host设为空即可实现在任意机器上登录访问。

2.使用Grant分配权限  
grant all on \*.* to 'username' @'url' identified by 'password';  
然后重启mysql.当前只是对指定ip进行权限分配的.还可以允许任何机器访问的.

注: 该命令与第一种方法得到的效果一模一样。username和password是连接当前数据库的用户名和密码.例如:grant all on \*.* to 'root' @'192.168.0.55' identified by '123456';这意思是说允许连接数据库用户名为root,密码是123456的ip为192.168.0.55进行远程访问该数据库的增删改查操 作.