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


相关推荐

  • Feign原理_feign源码

    Feign原理_feign源码feign是一种http客户端,可以让你通过简单地注解的方式,调用其他的http服务。feign提供的注解是@FeignClient,一直很好奇feign是怎么生效的,今天跟着代码一块看一下。要想使用feign的话,首先要在项目中打上@EnableFeignClients注解,从代码中可以看到,@EnableFeignClients通过@Import注解引入了Fei…

    2022年10月4日
    1
  • python+opencv图像模板匹配—多模板匹配

    python+opencv图像模板匹配—多模板匹配

    2021年10月6日
    39
  • linux(1)Mac上传文件到Linux服务器

    linux(1)Mac上传文件到Linux服务器前言我们使用mac时,想让本地文件上传至服务器,该怎么办呢windows系统,我们可以使用xftp或者rz命令,那么mac呢?mac系统,我们可以使用sftp、scp或者rz命令,本文介绍sft

    2022年7月31日
    6
  • SQL Server 2000安装教程图解

    SQLServer2000安装教程图解、、、下面网盘链接中的SQL2000数据库在Win7和Win10系统上安装都是可以正常使用的,只不过是Win10上安装的话,需要先替换一下原来C盘中的一个文件而已怎么替换请参考这个:http://www.cnblogs.com/iLoveBurning/p/8639711.html此版本针对XP和Win7系统的,Win…

    2022年4月6日
    39
  • redis info命令详解

    redis info命令详解

    2021年9月14日
    49
  • AppFabric_fabric安装

    AppFabric_fabric安装安装后,两种方式存储:XML,sqlserver建立缓存集New-CacheCluster-ProviderSystem.Data.SqlClient-ConnectionString “DataSource=[ServerName];InitialCatalog=[DBName];IntegratedSecurity=True”-SizeSmallRegiste

    2022年10月17日
    2

发表回复

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

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