php 移动 Drupal 站点后的 Mysql 异常 PDOException: SQLSTATE[HY000] [2013]

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/7270179/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-26 02:22:14  来源:igfitidea点击:

Mysql exception after moving drupal site PDOException: SQLSTATE[HY000] [2013]

phpmysqldrupal

提问by Stephan Celis

I just moved my drupal site to another domain/host

我刚刚将我的 Drupal 站点移至另一个域/主机

I moved the DB and now all my sites. But when I visit the website (juniorsteps.be), I get the following exception:

我移动了数据库,现在我所有的网站。但是当我访问网站 (juniorsteps.be) 时,出现以下异常:

PDOException: SQLSTATE[HY000] [2013] Lost connection to MySQL server at 'reading initial communication packet', system error: 111 in lock_may_be_available() (line 165 of /home/sites/webhosting/juniorsteps/juniorsteps/www/includes/lock.inc).

PDOException: SQLSTATE[HY000] [2013] 在“读取初始通信数据包”时失去与 MySQL 服务器的连接,系统错误:lock_may_be_available() 中的 111(/home/sites/webhosting/juniorsteps/juniorsteps/www/includes/lock 的第 165 行.inc)。

I googled it but I still don't find a solution.

我用谷歌搜索,但我仍然没有找到解决方案。

Hope someone can help.

希望有人能帮忙。

UPDATE

更新

As asked the code from line . It's the first line of the following function:

正如从 line 中询问的代码。这是以下函数的第一行:

function lock_may_be_available($name) {
  $lock = db_query('SELECT expire, value FROM {semaphore} WHERE name = :name', array(':name' => $name))->fetchAssoc();
  if (!$lock) {
    return TRUE;
  }
  $expire = (float) $lock['expire'];
  $now = microtime(TRUE);
  if ($now > $expire) {
    // We check two conditions to prevent a race condition where another
    // request acquired the lock and set a new expire time. We add a small
    // number to $expire to avoid errors with float to string conversion.
    return (bool) db_delete('semaphore')
      ->condition('name', $name)
      ->condition('value', $lock['value'])
      ->condition('expire', 0.0001 + $expire, '<=')
      ->execute();
  }
  return FALSE;
}

But to be honest I do not think the mistake is in my code since it works perfectly on my development server.

但老实说,我不认为错误出在我的代码中,因为它在我的开发服务器上运行良好。

回答by Eugen

Check your settings.php

检查您的 settings.php

  $databases = array (

  'default' => 

   array (

    'default' =>

    array (

      'database' => '333333',

      'username' => '333333',

      'password' => '3333333',

      'host' => '122.124.12.09', // check host -> maybe not localhost

      'port' => '3304',  // check port!

      'driver' => 'mysql',

      'prefix' => '',

      ),

    ),

   );

回答by 13rac1

I had the same issue. The development version of the site was setup for use with the Acquia development environment. The settings.phpwas incorrect. Delete all the Acquia specific information from the bottom lines of the sites/default/settings.phpfile.

我遇到过同样的问题。该站点的开发版本是为与 Acquia 开发环境一起使用而设置的。将settings.php是不正确的。从sites/default/settings.php文件底部的行中删除所有 Acquia 特定信息。

回答by Johan

This answer might help you:
"Lost connection to MySQL server" when trying to connect to remote MySQL server

此答案可能对您有所帮助:
尝试连接到远程 MySQL 服务器时,“与 MySQL 服务器的连接丢失”

And readup on the MySQL documentation on error 2013: server has gone away
http://dev.mysql.com/doc/refman/5.0/en/gone-away.html

并阅读有关错误 2013 的 MySQL 文档:http: server has gone away
//dev.mysql.com/doc/refman/5.0/en/gone-away.html