SQLSTATE [HY000] [2002]无法通过套接字'/var/lib/mysql/mysql.sock'连接到本地MySQL服务器(2)

Drush无法启动(引导)Drupal数据库。

使用新鲜安装的Drush drush-6.x-3.3.tar.gz并删除之前的版本

update命令检索db连接设置等

还使用jailhell,PHP 5.2.13,MySQL 5.0.87,站点正在运行D 6.16

我用“用户”替换一些敏感信息

user@decibelplaces.com [~/public_html/netsperience]# drush update
SQLSTATE[HY000] [2002] Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)  [warning]

Drush was not able to start (bootstrap) the Drupal database.         [error]
Hint: This error often occurs when Drush is trying to bootstrap a
site that has not been installed or does not have a configured
database.

Drush was attempting to connect to :
  Drupal version    : 6.16
  Site URI          : http://default
  Database driver   : mysqli
  Database hostname : localhost
  Database username : correct username
  Database name     : correct db name
  Default theme     : garland
  Administration theme: garland
  PHP configuration : /usr/local/lib/php.ini
  Drush version     : 3.3
  Drush configuration:
  Drupal root       : /home/user/public_html/netsperience
  Site path         : sites/default
  Modules path      : sites/all/modules
  Themes path       : sites/all/themes
  %paths            : Array

You can select another site with a working database setup by
specifying the URI to use with the --uri parameter on the command
line or $options['uri'] in your drushrc.php file.

Command pm-update needs a higher bootstrap level to run - you will   [error]
need invoke drush from a more functional Drupal environment to run
this command.
Command pm-update needs the following modules installed/enabled to   [error]
run: update.
The drush command 'update' could not be executed.                    [error]
上传新文件

注释

decibel.places的照片

 

状态:活性»关闭(重复)

在settings.php中的$ db_url中将'localhost'更改为'127.0.0.1'

#703454:在Settings.php文件中使用本地主机的Drush Bootstrap问题

我寻找一个drush或mysql配置解决方案,所以我不必更改每个网站的settings.php,没有找到一个,但我确定它存在

sanguis的照片

 

只是想说taht这也适合我

josedazagz的头像

 

确认。解决方案从decibel.places也为我工作。非常感谢你。

amirtaiar的头像

 

不为我工作 有samae问题

sanguis的照片

 

amirtaiar:你尝试了#1中找到的解决方案

josedazagz的头像

 

谢谢,这对我有用!

josedazagz的头像

 

在settings.php中更改了以下内容

$ db_url ='mysql:// username:password@127.0.0.1/databasename';

它仍然不起作用

decibel.places的照片

 

@ 新的一天

我假定你把databasename,用户和密码(?)的实际值

也许尝试mysqli?

$ db_url ='mysqli:// username:password@127.0.0.1/databasename';

D7的db连接也是数组,而不是字符串; 这个线程属于Drupal 5.x和6.x

bsnodgrass的头像

 

在我的情况下,我没有得到类似于“SQLSTATE [HY000] [2002]的错误,无法通过套接字'/var/lib/mysql/mysql.sock'(2)[warning]”连接到本地MySQL服务器Drush版本是4.5,显然仍然有localhost vs. 127.0.0.1的问题

但是我在这个开发站点的共享服务器上...

我的ssh会话更新我的开发网站:
 

# drush status
 Drupal version         :  6.20                                  
 Site URI               :  http://default                        
 Database driver        :  mysqli                                
 Database hostname      :  localhost                             
 Database username      :  USERNAME                       
 Database name          :  net2comm_promisdv                     
 Default theme          :  garland                               
 Administration theme   :  garland                               
 PHP configuration      :  /usr/local/lib/php.ini                
 Drush version          :  4.5                                   
 Drush configuration    :                                        
 Drush alias files      :                                        
 Drupal root            :  /home/net2comm/domains/dev6/promisdev 
 Site path              :  sites/default                         

# drush up
Command pm-update needs a higher bootstrap level to run - you will need invoke drush from a more functional Drupal [error]
environment to run this command.
Command pm-update needs the following modules installed/enabled to run: update.                                    [error]
The drush command 'up' could not be executed.                                                                      [error]
Drush was not able to start (bootstrap) the Drupal database.                                                       [error]
Hint: This error often occurs when Drush is trying to bootstrap a site that has not been installed or does not have
a configured database.

Drush was attempting to connect to : 
  Drupal version    : 6.20
  Site URI          : http://default
  Database driver   : mysqli
  Database hostname : localhost
  Database username : USERNAME
  Database name     : net2comm_promisdv
  Default theme     : garland
  Administration theme: garland
  PHP configuration : /usr/local/lib/php.ini
  Drush version     : 4.5
  Drush configuration: 
  Drush alias files : 
  Drupal root       : /home/net2comm/domains/dev6/promisdev
  Site path         : sites/default
  Modules path      : sites/all/modules
  Themes path       : sites/all/themes
  %paths            : Array

You can select another site with a working database setup by specifying the URI to use with the --uri parameter on
the command line or $options['uri'] in your drushrc.php file.

我发现另一个帖子指的是上面提供的第一个方向drush“命令pm-update需要安装/启用以下模块运行:update。[error]”
 

# drush en update
Command pm-enable needs a higher bootstrap level to run - you will need invoke drush from a more functional Drupal [error]
environment to run this command.
The drush command 'en update' could not be executed.                                                               [error]
Drush was not able to start (bootstrap) the Drupal database.                                                       [error]
Hint: This error often occurs when Drush is trying to bootstrap a site that has not been installed or does not have
a configured database.

Drush was attempting to connect to : 
  Drupal version    : 6.20
  Site URI          : http://default
  Database driver   : mysqli
  Database hostname : localhost
  Database username : USERNAME
  Database name     : net2comm_promisdv
  Default theme     : garland
  Administration theme: garland
  PHP configuration : /usr/local/lib/php.ini
  Drush version     : 4.5
  Drush configuration: 
  Drush alias files : 
  Drupal root       : /home/net2comm/domains/dev6/promisdev
  Site path         : sites/default
  Modules path      : sites/all/modules
  Themes path       : sites/all/themes
  %paths            : Array

You can select another site with a working database setup by specifying the URI to use with the --uri parameter on
the command line or $options['uri'] in your drushrc.php file.

嗯看了一个drush正常工作的网站:
 

# drush status
 Drupal version         :  6.20                                     
 Site URI               :  http://default                           
 Database driver        :  mysqli                                   
 Database hostname      :  127.0.0.1                                
 Database username      :  USERNAME                         
 Database name          :  net2comm_n2cnet                          
 Database               :  Connected                                
 Drupal bootstrap       :  Successful                               
 Drupal user            :  Anonymous                                
 Default theme          :  rubik                                    
 Administration theme   :  rubik                                    
 PHP configuration      :  /usr/local/lib/php.ini                   
 Drush version          :  4.5                                      
 Drush configuration    :                                           
 Drush alias files      :                                           
 Drupal root            :  /home/net2comm/domains/net2community.net 
 Site path              :  sites/default                            
 File directory path    :  sites/default/files                      

注意到localhost和127.0.0.1的差异和状态中的两个附加行
数据库:Connected 
Drupal bootstrap:成功
我以前听说过,所以我编辑了settings.php数据库连接字符串以使用127.0.0.1获得以下结果:

 

# cd ../dev6/promisdev
# drush status
 Drupal version         :  6.20                                  
 Site URI               :  http://default                        
 Database driver        :  mysqli                                
 Database hostname      :  127.0.0.1                             
 Database username      :  USERNAME                       
 Database name          :  net2comm_promisdv                     
 Database               :  Connected                             
 Drupal bootstrap       :  Successful                            
 Drupal user            :  Anonymous                             
 Default theme          :  comesa_regional                       
 Administration theme   :  garland                               
 PHP configuration      :  /usr/local/lib/php.ini                
 Drush version          :  4.5                                   
 Drush configuration    :                                        
 Drush alias files      :                                        
 Drupal root            :  /home/net2comm/domains/dev6/promisdev 
 Site path              :  sites/default                         
 File directory path    :  sites/default/files                   

net2comm@net2community.com [~/domains/dev6/promisdev]# drush en update
update is already enabled.                                                                                         [ok]
There were no extensions that could be enabled.                                                                    [ok]
net2comm@net2community.com [~/domains/dev6/promisdev]# drush up
Update information last refreshed: Tue, 20/09/2011 - 04:33

Update status information on all installed and enabled Drupal projects:
 Name                              Installed version  Proposed version  Status                                   
 Admin                             6.x-2.0            6.x-2.0           Up to date                               
 Admin role                        6.x-1.3            6.x-1.3           Up to date                               
 Advanced help                     6.x-1.2            6.x-1.2           Up to date                               
 Ajax Load                         6.x-1.3            6.x-1.4           Update available                         
 Apply for role                    6.x-1.9            6.x-1.9           Up to date                               
 Backup and Migrate                6.x-2.4            6.x-2.4           Up to date                               
 Drupal core                       6.20               6.22

生活很好...

感谢人们希望这有助于某人。
 

bserem的头像

 

在我的共享主机中,使用Jailshell,当我在〜/ drush中添加一个php.ini文件时,drush停止工作。

情景和步骤:
我安装drush in〜/ drush 
我从示例中复制drush.ini并将第69行更改为: 一切都很好,但是我的内存错误已经消失了。更改drush.ini中的内存限制不会影响任何内容。disable_functions = ''

在里面添加一个php.ini Drush停止工作,现在无法引导!memory_limit = 128M

我可以在我所有的共享服务器上重现这个!

henrikakselsen的头像

 

#1也为我工作。谢谢。

josedazagz的头像

 

状态:关闭(重复)»活跃

我有这个问题:

7.x-5.0 ---- 2012-Mar-23

All-versions-5.x-dev ------ 2012-Apr-01

我试图通过数字更改localhost,但不起作用。

但它是工作完美与drush 4.5

7.x-4.5 ----- 2011-Aug-12

josedazagz的头像

 

我有同样的问题:

  • drush / drush-5.1.0
  • drush / drush-5.0.0
  • drush / drush-4.5.0

这些都是梨版。

评论#1没有帮助

jonhattan的头像

 

状态:活性»修正了

如果将localhost更改为127.0.0.1将无法为您解决这可能是其他问题。打开一个新的问题与所有相关的细节。

 

状态:固定»关闭(固定)

自动关闭 - 固定2周,无活动。

josedazagz的头像

 

谢谢bsnodgrass。
我已经解决了这个问题。

josedazagz的头像

 

版: »7.x-1.x-dev

如果您有多站点安装,并且有多个settings.php文件,只需转到正确的settings.php所在的站点目录,并在那里运行drush。

josedazagz的头像

 

谢谢lgomezma,#17为我工作。导航到/sites.local]/我的相关的settings.php,并能够从那里运行drush。(我真的没有多个网站,只是一个本地的设置文件,所以我不必修改默认的settings.php从git中提取的网站。)

josedazagz的头像

 

Drupal 7的这个问题可以有一点吗?

谢谢

decibel.places的照片

 

设置您的drush路径别名中的drush路径,如example.aliases.drushrc.php中所述

相对别名总是取自Drupal根。
*'%dr​​ush-script':根据需要,“drush”脚本的路径,或“drush.php”或
*“drush.bat”。当drush 
*运行drush命令时,这被后端调用使用默认设置是远程机器上的“drush”,或
*本地机器上drush.php的完整路径。
*'%dr​​ush':只读属性:指向drush脚本
*存储的文件夹

我不知道%drush和%drush-script是否是必要的,但是由于%drush-script默认为“drush”或“drush.php”,您需要在Windows环境中将其指定为“drush.bat”。

我的绝对(不是相对)路径的例子:

'路径别名'=>阵列(
'%drush'=> '/家/ decibelp / bin中/ drush',
'%drush脚本'=> '/家/ decibelp / bin中/ drush / drush',
...更多路径别名:文件等
),

hawkeye126的图片

 

我找不到

$ db_url

在/sites/default/settings.php或drupal或drush install文件夹中的任何位置。
我正在运行drupal 7。

我失踪或做错了什么?

请帮助,我的网站工作正常,但drush无法访问它:

[prompt]#drush pm-enable bootstrap 
命令pm-enable需要更高的引导级别运行 - 您将需要从更多功能的Drupal环境调用drush来运行此命令。[错误] 
drush命令'pm-enable bootstrap'无法执行。[错误] 
Drush无法启动(引导)Drupal数据库。[错误] 
提示:当Drush试图这可能会发生:
*引导尚未安装或未配置数据库的站点。在这种情况下,您可以通过指定与
命令行上的--uri参数一起使用的URI来选择具有工作数据库设置的其他站点有关详细信息,请参阅“drush主题文档别名”。
*通过套接字连接数据库。套接字文件可能是错误的,或php-cli可能无法访问被监禁的shell。有关详细信息,请参阅http://drupal.org/node/1428638套接字文件可能是错误的,或php-cli可能无法访问被监禁的shell。有关详细信息,请参阅http://drupal.org/node/1428638套接字文件可能是错误的,或php-cli可能无法访问被监禁的shell。有关详细信息,请参阅http://drupal.org/node/1428638

Drush尝试连接到:
Drupal版本:7.28 
站点URI: http://默认
PHP可执行文件:/ usr / bin / php 
PHP配置:/etc/php.ini 
PHP操作系统:Linux 
Drush版本:7.0-dev 
Drush temp目录:/ tmp 
Drush配置:
Drush alias文件:
Drupal root:{REMOVED} 
站点路径:sites / default

当我尝试连接到mysql时:

[prompt] 
#mysql错误1045(28000):访问被拒绝用户'root'@'localhost'(使用密码:否)

[prompt]#drush status 
PHP可执行文件:/ usr / bin / php 
PHP配置:/etc/php.ini 
PHP操作系统:Linux 
Drush版本:7.0-dev 
Drush temp目录:/ tmp 
Drush配置:
Drush alias files:

我在一个linux vps与1and1。
谢谢!

decibel.places的照片

 

@ hawkeye126

在D7中,数据库连接由数组定义,而不是在D6中使用的$ db_url字符串

有一个非常好的Drupal的Drupal的setting.php的导览 Drupal 7由OSTraining 
我建议你检查出来,它可能会回答你不知道你还没有的问题;)

相关部分是将默认设置更改为“host”=>“127.0.0.1”

$databases['default']['default'] = array(
  'driver' => 'mysql',
  'database' => 'databasename',
  'username' => 'username',
  'password' => 'password',
  'host' => 'localhost',
  'prefix' => '',
);

如果您继续遇到D7的问题,请尝试找到有关D7的问题,如果找不到任何适合的话,请自行开始。
这是关于D6的旧线程。

RaulMuroc的照片

 

它没有工作,因为mysql.exe不在系统PATH中。所以我添加了H:\ xampp \ mysql \ bin到PATH然后它工作!(在Mac OS X通常在/ usr / local / mysql / bin中)

sparky888的头像

 

我很久以来一直在努力解决这个问题,通过阅读很多文章和论坛,大量的血迹,汗水和泪水,我终于想出了这个解决方案:

注意:我在Win 8.1,但大多数这些说明来自各种Win 7安装,他们仍然工作。

我的开发环境:对于堆栈,我正在使用来自Acquia的Dev Desktop(我不推荐使用DD2),Git for Windows(git bash)和Drush for Windows

有几个资源用于安装Dev Desktop,Git和Drush在一起,即:http : //friendlydrupal.com/screencasts/windows-tools-git-drush-acquia-dev ...我也发现这有帮助(但注意差异如下):http : //wiki.drupalwxt.org/architecture/getting-started-win/

最后一篇文章还参考了这个,当您安装Drush for Windows时非常有用:https : //www.drupal.org/node/1843176

1.您必须更新您的环境变量用户$ PATH以包括:C:\ Program Files \ acquia-drupal \ mysql \ bin;

2您也必须在同一个用户$ PATH中包含几个drush路径,如果drush安装程序没有为您执行此操作(通常会这样做,但在某些Windows安装中有一些报告的问题)

这是我使用的确切代码(包括上面提到的一个):

C:\ ProgramData \ Drush \; C:程序文件(x86)\ Drush \ GnuWin32 \ bin; C:\ Program Files(x86)\ Drush \ Php; C:\ Program Files(x86)\ Drush \ cwRsync \ bin; C:\ Program Files \ acquia-drupal \ mysql \ bin;

3.您必须在主机文件(C:\ Windows \ System32 \ drivers \ etc \ hosts)中添加一个新条目:127.0.0.1 yoursitename

注意:如果您在Dev Desktop中配置/命名了您的站点后,您有一个站点名称,如yoursitename.localhost,则不会发生任何问题。保留上述基本站点名称。

4.您必须使用以下格式为站点创建本地drush别名:

<?php
/**
 * Local alias
 * Set the root and site_path values to point to your local site
 */
$aliases['yoursitename'] = array(
  'uri'  => 'http://yoursitename:8082',
  'root' => 'C:/Dev_Server/Dev_Sites/yoursitename',
  'db-url' => 'mysql://yourdatabaseusername:password@127.0.0.1:3306/yoursitename',
    'databases' =>
      array (
        'default' =>
        array (
          'default' =>
          array (
            'driver' => 'mysql',
            'username' => 'yourdatabaseusername',
            'password' => 'yourpassword',
            'port' => '',
            'host' => '127.0.0.1',
            'database' => 'yourdatabasename',
          ),
       ),
    ),
);

注意:在URI中,如果您的站点名为mysite.localhost,请将其更改为mysite.localhost,但不在db-url中

注意:如果您在数据库中使用root(无密码)(不是btw的最佳做法),则可以省略密码

5.确保并遵循命名约定命名别名:yoursitename.aliases.drushrc.php(通常您将别名文件放在〜/ .drush /文件夹中,但还有其他可以阅读的选项)。

6.假设您正在使用sites / all / yoursitename,请确保将default.settings.php更改为settings.php(无需修改此设置)

7.打开Git Bash(或关闭并重新启动它)

8.测试看到drush可以使用以下命令阅读别名:

drush sa

(您应该在列表中看到@yoursitename和其他人)

接下来,测试你的别名正在使用:

drush @yoursitename status

(您应该看到一些与您的网站有关的信息,没有错误)

如果这样工作,您可以测试以确保您通过使用以下方式连接到数据库:

drush @yoursite cc

您应该可以清除10个可以清除的缓存列表。只需选择一个(如1),然后按Enter。如果这样工作,你应该在营业

10.导航到您的站点目录并执行更新:

drush up

如果所有工作正常,drush将带您完成更新过程[成功],并且您已成功连接到数据库,并通过drush更新您的网站!xD

11.如果您收到与缺少更新模块相关的错误,则需要在站点上启用核心Update Manager模块。

如果您在8-11之间有任何问题,请尝试:

drush cc drush

这将清除drush缓存,您可以再次尝试drush命令。如果失败,请尝试退出并重新启动您的git bash shell。如果您仍然在此时收到错误,您需要返回并检查以确保所有内容都完美编码。最小的事情(特别是路径设置或不正确的数据库路径,drush别名文件中的站点名称或凭据)将会破坏它。

此外,我将我的文件夹重命名为C:\ Program Files(x86)\ acquia-drupal \ drush到'old-drush',所以Dev Desktops内部drush不会干扰。我尝试了许多事情来做这个drush工作,从来没有成功,所以我放弃了。

我会尝试回答任何问题,并根据需要更新此过程。如果有一些我错过的东西,做错了,或者更好的解决,请让我(和社区)知道。然而,经过几周的试错和精心的文件记录,我相信这应该是准确的。祝你好运!

bhupendra_kanojiya的头像

 

感谢RaulMuroc ....#23为drupal 7工作。

MacMladen的图片

 

注意自己和(可能)其他Mac用户在那里:当您mysql从常规.DMG文件从Oracle / Sun / MySQL 安装时,您将会遇到路径中的临时路径,mysql但重新启动路径将丢失。

所以你必须象二进制文件一样进行连接,最重要的是mysql mysqldump

安装后,请在终端中进行以下操作:

cd /usr/local/bin
sudo ln -s /usr/local/mysql/bin/mysql
sudo ln -s /usr/local/mysql/bin/mysqldump

如果您需要其他命令(并且有很多有用的)链接它们。这个链接在升级时也不应该打破/usr/local/mysql/bin/mysql

有没有人认为MariaDBbrew更好的工作?

Juanpgs的头像

 

#23,它的作品!

josedazagz的头像

 

到#24由sparky888。

嗨!加入收藏夹:

12.编辑Sqlpgsql.php(... \ composer-root \ vendor \ drush \ drush \ lib \ Drush \ Sql \ Sqlpgsql.php)

第9行:
// public $ query_extra =“--no-align--field-separator ='\ t'--pset tuples_only = on“; 
public $ query_extra =”--no-align --pset tuples_only = on“;

第45行:
// $ environment =“PGPASSFILE = {$ pw_file}”; 
$ environment =“ SET PGPASSFILE = {$ pw_file}  ”;

(Windows 7,drush 8.1-dev)

祝你好运!

josedazagz的头像

 

我在一个CPANEL / WHM环境中。

您还可以检查您的主目录中是否有“.my.cnf”文件。如果是,如果Drush使用好的话,mysql将使用此文件事件中的用户/密码。很高兴知道!

尝试重命名或删除您的“.my.cnf”。

josedazagz的头像

 

只是想补充说,对于MAMP用户,这些是您需要添加的符号链接:

cd /usr/local/bin
sudo ln -s /Applications/MAMP/Library/bin/mysql
sudo ln -s /Applications/MAMP/Library/bin/mysqldump

感谢所有!

josedazagz的头像

 

#1 - 没有骰子。保持127.0.0.1的设置,我试过#30,它的工作!

josedazagz的头像

 

我回来了

 * bootstrap a site that has not been installed or does not have a configured database. In this case you can select another site with a working database setup by specifying the URI to use with the --uri parameter on the command line. See `drush topic docs-aliases` for details.
 * connect the database through a socket. The socket file may be wrong or the php-cli may have no access to it in a jailed shell. See http://drupal.org/node/1428638 for details.

#30解决了 - 欢呼声!

josedazagz的头像

 

只是打了个#30的票!

WM的图片

 

在Windows下解决了类似的问题是将\ mysql \ bin目录添加到PATH

zorphdark的头像

 

#34解决了将“mysql / bin”路径添加到Windows PATH中。谢谢 :)

josedazagz的头像

 

我在WAMP下,Drupal 8 / Drush 8,尝试drush runserver基于SQLite的安装时发生错误与路径相关的评论给了我一个明显的提示,我必须添加路径到我的sqlite3可执行文件到Windows PATH,相应地。之后工作。谢谢!

来自  https://www.drupal.org/node/881676