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


相关推荐

  • unzip解压命令出现错误_软件解压不了怎么办

    unzip解压命令出现错误_软件解压不了怎么办寻找gzip获取一个网页数据返回的编码类型是gzip,我该怎么解压缩HTTP头获取?如何用vb获取网络上的xml文件,并解析内容关于GZIP的解码怎样解gzip的压缩请问Wininet是否可以进行Gzip的http传输,尤其是post的时候!如果可以如何实现?关于GZIP格式解压缩HTTP数据包的问题,我使用ZLIB为什么必须先保存文件,内存解压缩出错

    2022年9月6日
    2
  • C语言求最大公约数和最小公倍数(思路清晰+拓展)[通俗易懂]

    C语言求最大公约数和最小公倍数(思路清晰+拓展)[通俗易懂]最大公约数的求法首先了解它的一般求法(欧几里得算法):假设存在两个数A和B,假如A%B的结果不为0,那么A和B的最大公约数是B与A%B的最大公约数,一直往下计算,直到后者为0,此时的最大公约数为A’(注意不是A而是A’)。就比如上边的例子,当A%B==0的时候,最大公约数就是B了,这个A’就代表B。最大公约数的代码:(基于C++实现的函数)intgcd(inta,intb){ in…

    2022年5月16日
    50
  • 最全java面试题及答案(208道)「建议收藏」

    最全java面试题及答案(208道)「建议收藏」本文分为十九个模块,分别是:「Java基础、容器、多线程、反射、对象拷贝、JavaWeb、异常、网络、设计模式、Spring/SpringMVC、SpringBoot/SpringCloud、Hibernate、MyBatis、RabbitMQ、Kafka、Zookeeper、MySQL、Redis、JVM」,如下图所示:共包含208道面试题,本文的宗旨是为读者朋友们整理一份详实而又权威的面试清单,下面一起进入主题吧。Java基础1.JDK和JRE有什么区别?…

    2022年8月10日
    6
  • AWStats日志分析

    AWStats日志分析AWStats日志分析系统介绍1.AWStats日志分析系统(1)Peri语言开发的一款开源日志分析系统(2)可用来分析Apache、Samba、Vsftpd、IIS等服务器的访问日志(3)信息结合crond等计划任务服务,可对日志内容定期进行分析部署AWStats日志分析系统1.安装AWStats软件包2.为要统计的站点建立配置文件3.修改站点统计配置文件…

    2022年7月16日
    20
  • 数据集网站_drone无人机模拟训练软件

    数据集网站_drone无人机模拟训练软件中国人不骗中国人。csdn李居然有人卖几十块智商税。其实只要外网一查就免费。看我来砸他生意。免费万岁!共享永存!GitHub-dasmehdix/drone-dataset:Dronedatasettoguideenemydrones(withsometools)…

    2022年8月15日
    2
  • 第58章、拍照功能实现(从零开始学Android)

    第58章、拍照功能实现(从零开始学Android)Android有两种拍照方法,一种是直接调用系统的照相Intent,使用onActivityResult获取图片资源或者指定图片路径,拍照返回成功后去指定路径读取图片;一种是用SurfaceView自定义界面,添加业务个性化功能。一、第一种方法1、设计界面  (1)、布局文件  打开activity_main.xml文件。  输入以下代码: 

    2022年6月18日
    26

发表回复

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

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