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)
全栈程序员-站长的头像全栈程序员-站长


相关推荐

  • 计算机的发展历史_计算器的由来和故事

    计算机的发展历史_计算器的由来和故事本文主要介绍计算机的发展历史。1概述计算工具的演化经历了由简单到复杂、从低级到高级的不同阶段,从“结绳记事”中的绳结到算筹、算盘、计算尺、机械计算机等,它们在不同的历史时期发挥了各自的历史作用,同时也启发了现代电子计算机的研制思想。1889年,美国科学家赫尔曼·何乐礼研制出以电力为基础的电动制表机,用以储存计算资料。1930年,美国科学家范内瓦·布什造出世界上首台模拟电子计算机。…

    2022年8月31日
    1
  • java认证考试试卷_java认证考试试题及答案

    java认证考试试卷_java认证考试试题及答案java认证考试试题及答案故答案为C。12.Whatistheresultafterthefollowingcodeexecutes?1shorts=0x00FD;2byteb=(byte)s;3System.out.println(b);Select1correctanswer:A.Compiletimeerrorinline1B.Comp…

    2022年7月7日
    21
  • js,jquery,css,html5特效

    包含js,jquery,css,html5特效,源代码本文地址:http://www.cnblogs.com/roucheng/p/texiao.html2017新年快乐特效jQuery最新最全

    2021年12月28日
    37
  • 完整版—Android studio入门教程

    完整版—Android studio入门教程AS的安装及第一个AS中android项目的搭建前言:前段时间公司搞了个”校企合作”的项目,要求公司人员去学校对学生进行阶段性的专业培训,荣幸的我被派去当了回“老师”;哈哈,真的有点“打肿脸充胖子”的感觉;不过,也算是复习下as的安装过程吧,顺便有空了就记录下来,后面万一忘了也好查看。正文:首先需要确定好电脑是否有安装java环境:直接电脑桌面windows+R输入cmd…

    2022年6月7日
    42
  • C语言判断回文字符串(指针)

    C语言判断回文字符串(指针)东北大学在线编程社区problem1678题目描述:编写函数:intfun(char*p),功能是判断一个字符串是否是回文字符串(提示:回文字符串是指正读和反读都一样的字符串),要求从主函数中由键盘输入字符串,调用函数fun后,根据函数fun的返回值,主函数输出是否为回文字符串的判断。输入样例:haah输出样例:是回文串//该代码使用MicrosoftVisualStudio2019编写#define_CRT_SECURE_NO_WARNINGS#include<stdio.

    2022年5月4日
    50
  • MFC之COleVariant[通俗易懂]

    MFC之COleVariant[通俗易懂]COleVariant 本质上是一个枚举,用同一种类型来表达不同的子类型。如同boost中的variant。例子COleVariantvar(3.6f);floatv=var.fltVal;CStringstr(“testCOleVariant”);COleVariantvar2(str);CStringcpStr(var2.bstrVal);例子CStrin

    2022年7月18日
    18

发表回复

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

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