前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >drupal 没有mysql,Drupal安装无法连接到MySQL服务器,但是已经存在「建议收藏」

drupal 没有mysql,Drupal安装无法连接到MySQL服务器,但是已经存在「建议收藏」

作者头像
全栈程序员站长
发布2022-09-09 12:51:13
8K0
发布2022-09-09 12:51:13
举报

大家好,又见面了,我是你们的朋友全栈君。

I’m getting the following error installing drupal 7:

Failed to connect to your database server. The server reports the following message: SQLSTATE[HY000] [2003] Can’t connect to MySQL server on ‘myservername’ (13).

I am running MySQL on one windows server and httpd on another linux. MySQL is running just fine and on the httpd server I can connect just fine to the MySQL, as follows:

mysql -h dbserver -p –port=3001 -u drupal

Similarly I can run mysqli and pdo and it connection just fine too from my httpd:

$servername = “dbserver”;

$username = “drupal”;

$password = “xxx”;

$dbname = “drupal”;

$port = 3001;

conn = new mysqli(servername, username, password, dbname, port);

if ($conn->connect_error) {

die(“Connection failed: ” . $conn->connect_error);

}

echo “Connected successfully”;

$conn->close();

try {

conn = new PDO(“mysql:host=servername;dbname=dbname;port=port”, username, password);

// set the PDO error mode to exception

$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);

echo “Connected successfully”;

}

catch(PDOException $e)

{

echo “Connection failed: ” . $e->getMessage();

}

$conn=null;

?>

So there is nothing wrong on my web server or php or mysql. It’s just through the installation that it fails. I’ve been in the advanced and entered all the correct details.

Any idea? I looked and there was no apache log and I couldn’t figure out how to increase error reporting during install or find exactly where it does the database connection check..

thanks.

解决方案

Can you confirm you have dbserver’s ip mapped.

Go to terminal and type : “ping dbserver” and please post result.

EDITED: This situation was caused by a security policy of the linux distro where the apache server is setup that doesn’t allow it to connect to remote mysql instances. For solving this situation go to terminal and type sudo setenforce 0, that way linux won’t enforce such strict webserver behaviour.

发布者:全栈程序员栈长,转载请注明出处:https://javaforall.cn/162248.html原文链接:https://javaforall.cn

本文参与 腾讯云自媒体分享计划,分享自作者个人站点/博客。
如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
相关产品与服务
云数据库 MySQL
腾讯云数据库 MySQL(TencentDB for MySQL)为用户提供安全可靠,性能卓越、易于维护的企业级云数据库服务。其具备6大企业级特性,包括企业级定制内核、企业级高可用、企业级高可靠、企业级安全、企业级扩展以及企业级智能运维。通过使用腾讯云数据库 MySQL,可实现分钟级别的数据库部署、弹性扩展以及全自动化的运维管理,不仅经济实惠,而且稳定可靠,易于运维。
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档