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

drupal 没有mysql,Drupal安装无法连接到MySQL服务器,但是已经存在「建议收藏」I’mgettingthefollowingerrorinstallingdrupal7:Failedtoconnecttoyourdatabaseserver.Theserverreportsthefollowingmessage:SQLSTATE[HY000][2003]Can’tconnecttoMySQLserveron’myserv…

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

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

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.net/162248.html原文链接:https://javaforall.net

(0)
全栈程序员-站长的头像全栈程序员-站长


相关推荐

  • Android 多线程编程实验_android UI线程

    Android 多线程编程实验_android UI线程线程的基本用法Android的多线程编程与Java多线程编程基本是使用相同的语法,比如定义一个线程只需要新建一个类继承自Thread,重写父类的run()方法classMyThread:Thread(){overridefunrun(){//编写具体的逻辑}}启动这个线程也很简单,创建MyThread的实例,调用start()方法,这样run()方法中的代码就会在子线程中运行了MyThread().start().

    2025年6月8日
    0
  • Python虚拟环境包管理工具

    Python虚拟环境包管理工具

    2022年3月12日
    34
  • Guava之Stopwatch「建议收藏」

    Guava之Stopwatch「建议收藏」Guava之Stopwatch计时器Stopwatch用来计算经过的时间(精确到纳秒)。这个类比调用System.nanoTime()优势在于:性能表现形式更丰富一、类声明以下是com.google.common.base.Stopwatch类的声明:publicfinalclassStopwatchextendsObject二、类方法方法类型方法…

    2022年6月23日
    97
  • 商品搜索引擎–商品推荐

    商品搜索引擎–商品推荐

    2020年11月12日
    210
  • linux卸载系统自带jdk_win10自带虚拟机好用吗

    linux卸载系统自带jdk_win10自带虚拟机好用吗注:最小化安装不需要执行!!!rpm-qa|grep-ijava|xargs-n1rpm-e–nodepsrpm-qa:查询所安装的所有rpm软件包grep-i:忽略大小写xargs-n1:表示每次只传递一个参数rpm-e–nodeps:强制卸载软件…

    2022年10月1日
    0
  • python在线音乐播放器_python实现音乐播放器「建议收藏」

    python在线音乐播放器_python实现音乐播放器「建议收藏」python是一个比较活泼的语言,它可以很快速、很方便地实现很多有意思的东西。最近,学习了一下如何使用python制作一个简单的音乐播放器,整体的效果如下图所示。所需要的导入的库tkinterostimethreadingpygame如果没有安装这个库,简单粗暴的pipinstall+库例如,我没有安装过pygame这个库,准备工作下载音乐,喜欢的歌曲,选择mp3格式这里,给大家提供一个…

    2022年6月26日
    38

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

关注全栈程序员社区公众号