我有`pdoException:sqlstate [hy000] [2002]使用drush [关闭]时没有这样的文件或目录 -- drush 领域 drupal 相关 的问题

I've got `PDOException: SQLSTATE[HY000] [2002] No such file or directory` when using drush [closed]


21
vote

问题

中文
关闭。这个问题需要更多聚焦。它目前不接受答案。

想要改进这个问题?更新问题,因此它仅拍摄了一个问题,只有编辑此帖。

关闭 3年前

改善这个问题

我第一次安装醉酒(因此它可能是一个配置错误),我正在尝试更新到Drupal的最新核心版本。

醉酒给我这个错误 - 我在一个osx盒子上。

  dev5:clientnamedirectory my.name$ drush pm-update projects drupal-7.25 <h1>Additional uncaught exception thrown while handling exception.</h1>  <h2>Original</h2><p>PDOException: SQLSTATE[HY000] [2002] No such file or directory in drupal_get_installed_schema_version() (line 155 of /Users/my.name/Sites/proface/includes/install.inc).</p>  <h2>Additional</h2>  <p>PDOException: SQLSTATE[HY000] [2002] No such file or directory in system_list() (line 165 of /Users/my.name/Sites/clientnamedirectory/includes/module.inc).</p><hr />  Drush command terminated abnormally due to an unrecoverable error.   
英文原文

I installed Drush for the first time (so it may be a configuration error) and I'm trying to update to the latest core version of Drupal.

Drush is giving me this error - I'm on an OSX box.

dev5:clientnamedirectory my.name$ drush pm-update projects drupal-7.25 <h1>Additional uncaught exception thrown while handling exception.</h1>  <h2>Original</h2><p>PDOException: SQLSTATE[HY000] [2002] No such file or directory in drupal_get_installed_schema_version() (line 155 of /Users/my.name/Sites/proface/includes/install.inc).</p>  <h2>Additional</h2>  <p>PDOException: SQLSTATE[HY000] [2002] No such file or directory in system_list() (line 165 of /Users/my.name/Sites/clientnamedirectory/includes/module.inc).</p><hr />  Drush command terminated abnormally due to an unrecoverable error. 
  
         
         

回答列表

43
 
vote

这就是我在麦斯斯上解决它的方式:

  sudo mkdir /var/mysql sudo ln -s /Applications/MAMP/tmp/mysql/mysql.sock /var/mysql/mysql.sock   

源:在mamp上使用疏浚。

 

This was how I solved it on macOS:

sudo mkdir /var/mysql sudo ln -s /Applications/MAMP/tmp/mysql/mysql.sock /var/mysql/mysql.sock 

Source: Working with Drush on Mamp.

 
 
 
 
38
 
vote

在数据库配置中的文件设置为drupal站点,尝试将主机更改为127.0.0.1而不是localhost。

替换默认值: '宿主'=&gt; 'localhost',

: '宿主'=&gt; '127.0.0.1',

我在OS X XAMPP上有这个错误,但解决方案也应该在这里申请。作为Clive提到的,它是一个MySQL连接问题。 此帖在潜在的问题上有更多。

 

In your database configuration in the file settings.php for the Drupal site, try changing the host to 127.0.0.1 instead of localhost.

replace the default: 'host' => 'localhost',

with: 'host' => '127.0.0.1',

I've had this error on OS X XAMPP, but the solution should apply here as well. As Clive mentioned, its a MySQL connection issue. This post has more on the underlying issue.

 
 
     
     
11
 
vote

说明

pdoException - 错误2002 意味着你的Drush无法通过套接字文件(例如 php.ini 中配置的套接字文件(例如 /tmp/mysql.sock )连接到MySQL本地数据库服务器。

这实际上与 drush IT-self有关,它是您的PHP配置,并且可以通过以下方式再现:

  php -r "new PDO('mysql:host=localhost;port=3306;charset=utf8;dbname=dbname', 'root', 'root');"   

修复

如果您的MySQL正常工作,请确保这两个文件:

  1. mysql_config --socket

    或: mysqladmin variables | grep socket

  2. php -i | grep -w default_socket

    或: php -r 'phpinfo();' | grep -w default_socket

匹配并指向同一文件,它们都存在。

如果没有,请检查哪一个是正确的:

  mysql --socket=/path/to/mysql.sock   
然后通过以下解决方案之一解决问题:
  • 使符号链接指向工作 998876610 unix套接字(用于mAMP,请参阅安德鲁回答),

      例如,如果您使用的是MAMP,则可以将符号链接到默认位置:
        /tmp/mysql.sock1  
  • /tmp/mysql.sock2 ,或 /tmp/mysql.sock4

  • 指定 /tmp/mysql.sock6 /tmp/mysql.sock7 /tmp/mysql.sock7 /tmp/mysql.sock8 变量,例如,

      /tmp/mysql.sock9  

  • 故障排除

    其他边缘案例可能是:

    • 错误权限(例如,到父文件夹),
    • 你不在空间中,
    • 您已经多个PHP版本,检查您使用的是您使用的,您正在更改哪种配置,
    • 使用xdebug调试:

      • php.ini0
      • php.ini1
      • 或设置 php.ini2 php.ini3
    • 调试:在与 php.ini4的上的OS X上,在Linux上使用 php.ini5
    • 另请参见: MySQL连接不起作用:2002没有这样的文件或目录
     

    Explanation

    The PDOException - error 2002 means that your drush can't connect to MySQL local database server through the socket file (e.g. /tmp/mysql.sock) as configured in your php.ini.

    This is actually not much related to drush it-self, it's your PHP configuration and that error can be reproduced by:

    php -r "new PDO('mysql:host=localhost;port=3306;charset=utf8;dbname=dbname', 'root', 'root');" 

    Fix

    If your MySQL works correctly, make sure these two files:

    1. mysql_config --socket

      or: mysqladmin variables | grep socket

    2. php -i | grep -w default_socket

      or: php -r 'phpinfo();' | grep -w default_socket

    matching and points to the same file and they both exists.

    If not, check which one is correct by:

    mysql --socket=/path/to/mysql.sock 

    then fix the problem by one of following solutions:

    • make the symbolic link to point to the working mysql.sock unix socket (for MAMP, see Andrew answer),

      • for example, if you're using MAMP, you can make a symbolic link to the default location:

        sudo ln -vs /Applications/MAMP/tmp/mysql /var/mysql 
    • correct path of your pdo_mysql.default_socket, mysql.default_socket or mysqli.default_socket in your php.ini

    • specify unix_socket in your settings.php in your $databases variable, e.g.

      $databases['default']['default'] = array(   // ...   'unix_socket' => '/var/mysql/mysql.sock', 

    Troubleshooting

    Other edge-cases could be:

    • wrong permissions (e.g. to the parent folders),
    • you're out of space,
    • you've multiple PHP versions, check which exactly are you using and which config are you changing,
    • Debug with XDebug:

      • echo '<?php xdebug_start_trace("/tmp/foo.log");' > init.php
      • drush -c init.php ev 'Database::getConnection("default", "default");'
      • or set xdebug.show_exception_trace=1 in your xdebug.ini
    • Debug: on OS X with sudo dtruss -fn mysqld, on Linux with strace
    • See also: MySQL connection not working: 2002 No such file or directory at SO
     
     
    6
     
    vote

    我正在使用mamp pro并发出同样的问题。我可以找到修复它的最简单方法是在Settings.php文件中将以下行添加到$ Database数组中。

      php.ini6  

    完整它应该如下所示:

      php.ini7  

    我得到的确切错误看起来像这样:

    处理异常时抛出的其他未捕获的异常。

    原始

    pdoException:sqlstate [hy000] [2002]没有drupal_is_denied()中的文件或目录(... 附加

    pdoException:sqlstate [hy000] [2002]没有_registy_check_code()中的文件或目录(...


    drush命令由于不可恢复的错误而异常终止。

     

    I'm using MAMP Pro and had this same issue. The easiest way I could find to fix it was to add the following line to your $database array in the settings.php file.

    'unix_socket' => '/Applications/MAMP/tmp/mysql/mysql.sock', 

    In full it should look like this:

    $databases = array (     'default' =>      array (         'default' =>         array (             'database' => 'your_database_name',             'username' => 'username',             'password' => 'password',             'host' => 'localhost',             'port' => '',             'driver' => 'mysql',             'prefix' => '',             'unix_socket' => '/Applications/MAMP/tmp/mysql/mysql.sock',         ),     ), ); 

    The exact error I was getting looked like this:

    Additional uncaught exception thrown while handling exception.

    Original

    PDOException: SQLSTATE[HY000] [2002] No such file or directory in drupal_is_denied() (line 2193 of ...

    Additional

    PDOException: SQLSTATE[HY000] [2002] No such file or directory in _registry_check_code() (line 3477 of ...


    Drush command terminated abnormally due to an unrecoverable error.
     
     
     
     
    3
     
    vote

    我用以下步骤解决了这个,类似于上一个回复,但不一样。

    添加一个symlink:

      php.ini8  

    查找使用的php.ini:

      php.ini9  

    将以下设置添加到php.ini:

      drush0  
     

    I solved this with the following steps, similar to previous replies but not the same.

    Add a symlink:

    sudo mkdir /var/mysql sudo ln -s /Applications/MAMP/tmp/mysql/mysql.sock /var/mysql/mysql.sock 

    Find the php.ini being used:

    php -i | grep php.ini 

    Add the following settings to php.ini:

    pdo_mysql.default_socket= /var/mysql/mysql.sock mysql.default_socket = /var/mysql/mysql.sock mysqli.default_socket = /var/mysql/mysql.sock 
     
     
    1
     
    vote

    这是由于PHP / SQL配置中的配置错误。在Web服务器使用的套接字和命令行使用的情况下,在某个套接字中配置了不同的。我建议您检查MySQL配置以查看使用的UNIX套接字,然后确保所有PHP.ini配置和编译中使用相同的值。

    如果无法修复配置,则以下步骤应该工作:

    1. 获取Drush 5.x的开发版本(http://ftp.drupal.org/files/projects/drush-all-versions-5.x-dev.tar.gz)并安装它。这可能会导致其他问题,但整体相当稳定。
    2. 在Drupal站点中的
    3. settings.php删除数据库连接的主机和端口设置,并在"UNIX_SOCKET" =&gt中添加; '/path/to/mysql.sock'替换它们。

    如果所有这一切似乎复杂,替代方案是从localhost到127.0.0.1中的setting.php中的主机将主机更改为127.0.0.1。这将使该网站较慢,但对于开发网站,它可能不明显或重要。对于您要使用UNIX套接字的生产网站,应整理配置。

     

    This is due to a configuration error in your PHP/SQL configurations. Somewhere the socket that your webserver uses and the command line uses is configured differently. I recommend checking your MySQL configuration to see what unix socket is in use, and then make sure the same value is used in all php.ini configurations and compiles.

    If you can't fix the configuration the following steps should work:

    1. Get the development version of Drush 5.x (http://ftp.drupal.org/files/projects/drush-All-versions-5.x-dev.tar.gz) and install that instead. This might cause other issues, but overall its pretty stable.
    2. In your Drupal sites settings.php remove the host and port settings for the database connection and add in a 'unix_socket' => '/path/to/mysql.sock' to replace them.

    If all this seems to complicated, an alternative is to change the host in setting.php from localhost to 127.0.0.1. This will make the site slower, but for a development site it may not be noticeable or important. For a production site you want to use the unix socket and should sort out the configuration.

     
     
     
     
    1
     
    vote

    在MAC上找到了更容易/替代的方法来安装DRUSH:

    安装 homebrew 通过粘贴在独立终端中

      /usr/bin/ruby -e "$(curl -fsSL https://raw.github.com/gist/323731)"   
    然后通过从同一终端运行以下内容来添加润发
      brew install drush   

    运行醉酒状态现在运行正常。

     

    Found an easier / alternative way to install drush on a Mac:

    Install homebrew by pasting this in a stand alone terminal

    /usr/bin/ruby -e "$(curl -fsSL https://raw.github.com/gist/323731)" 

    Then add drush by running the following from the same terminal

    brew install drush 

    Running drush status runs fine now.

     
     
    1
     
    vote

    如果您正在使用MySQL.com安装MySQL,则只需将PHP点位于 99887662 文件的正确位置。

    php.ini ,添加/修改这两行:

      mysql.default_socket = /tmp/mysql.sock mysqli.default_socket = /tmp/mysql.sock   
    要查找php.ini的位置(它可能不存在),请使用此
      php -i | grep php.ini   

    如果 php.ini 文件不存在,则创建它。

     

    If you're working with the MySQL.com installation of MySQL, you just need to point PHP at the right location for the .sock file.

    In your php.ini, add/amend these two lines:

    mysql.default_socket = /tmp/mysql.sock mysqli.default_socket = /tmp/mysql.sock 

    To find the location of your php.ini (it may not exist yet), use this

    php -i | grep php.ini 

    If the php.ini file doesn't exist there yet, create it.

     
     
    0
     
    vote

    同意drupal无法找到mysql套接字的答案。另一个答案帮助了我,但是安装了安装官方Oracle MySQL服务的不完整。即,mysql.sock文件的默认位置。所以这里是根据您的用例的推荐答案:

    如果使用官方MAMP包中包含的MySQL,请使用@andrew亚历山大的答案:

      sudo mkdir /var/mysql sudo ln -s /Applications/MAMP/tmp/mysql/mysql.sock /var/mysql/mysql.sock   

    对于官方Oracle mysql:

      sudo mkdir /var/mysql sudo ln -s /tmp/mysql.sock /var/mysql/mysql.sock   
     

    Agree with other answers that Drupal cannot find the mysql socket. The other answers helped me but were incomplete for installing with the official Oracle Mysql service installed. Namely, the default location of the mysql.sock file. So here is a recap of my recommended answers depending on your use case:

    If using mysql as included by the official MAMP package, use @Andrew Alexander's answer:

    sudo mkdir /var/mysql sudo ln -s /Applications/MAMP/tmp/mysql/mysql.sock /var/mysql/mysql.sock 

    For the official Oracle MYSQL:

    sudo mkdir /var/mysql sudo ln -s /tmp/mysql.sock /var/mysql/mysql.sock 
     
     
    0
     
    vote

    对于MAMP 4设置,解决方案正在检查"在命令行上提供此版本。"

    mamp配置

     

    For a MAMP 4 setup, the solution was checking "Make this version available on the command line."

    MAMP configuration

     
     
    0
     
    vote

    我在终端中获取了以下消息:

    (MAMP Pro + PHP 7)

    bolexquote 由于不可恢复的错误,Drush命令异常终止。
    [错误] PDOException:sqlstate [hy000] [2002]没有这样的文件或目录 在 drupal component decigendenceIngress phparraycontainer-&gt; createService() blockquote

    我在这些指令

    中解决了问题
     

    I got the following message in terminal:

    (MAMP PRO + PHP 7)

    Blockquote Drush command terminated abnormally due to an unrecoverable error.
    [error] PDOException: SQLSTATE[HY000] [2002] No such file or directory in Drupal\Component\DependencyInjection\PhpArrayContainer->createService() Blockquote

    I solved the problem with the help of these instructions

     
     
    0
     
    vote

    我忘了我的本地mysql在一个唯一的端口号上运行,所以我很困惑为什么我在另一个本地网站上审核我的配置之前我才会收到这一点。

      $databases['default']['default'] = array (   'database' => 'hou',   'username' => 'root',   'password' => '',   'prefix' => '',   'host' => '127.0.0.1',   'port' => '3306',   'driver' => 'mysql',   'collation' => 'utf8mb4_general_ci', );   
     

    I forgot that my local mysql runs on a unique port number so I was confused why I was getting this until I reviewed my configuration on another local site.

    $databases['default']['default'] = array (   'database' => 'hou',   'username' => 'root',   'password' => '',   'prefix' => '',   'host' => '127.0.0.1',   'port' => '3306',   'driver' => 'mysql',   'collation' => 'utf8mb4_general_ci', ); 
     
     

    相关问题

    1  疏浚不适用于PHP 5.4.23  ( Drush not working on php 5 4 23 ) 
    我的润滑是安装在/ usr / local / lib / php / drush上;我现在已经从那里删除了它,并在/ usr / share / drush上安装它。 我运行以下命令。 chmod u+x /usr/share/drush/drush ln -s /usr/share/drush/drush /...

    3  我可以在没有网站别名的情况下使用--Remote-host吗?  ( Can i use remote host without a site alias ) 
    我正在尝试使用drush以执行一些命令作为我的CI / CD工作流的一部分。问题是,由于它的灵活性,我想避免使用基本上意味着在构建过程中写入临时文件的站点别名(我真的希望避免这种情况)。 但是,我一直在尝试使用--Remote-host, - remote-user和 - 行进(例如'drush --remote-...

    1  PM-UPDATE失败“SH:Backend = 2:未找到命令”  ( Pm update fails sh backend 2 command not found ) 
    pm-download命令正常工作,因此我可以单独更新模块,但我不能在批量中完成。疏士6.2.0和6.1.0都给出错误。 drush up --debug 的输出是下面的。 引导到阶段0. [0.01秒,2.24 MB] [Bootstrap] Drush Bootstrap阶段:_drush_boot...

    0  可以“醉酒制作”命令使用缓存的临时文件?  ( Can drush make command use cached temporary files ) 
    使用疏浚6.2.0,使用后 $ drush make build_my_project.make my_project/ 多次,它会导致 .. 找到makefile:drupal-org.make 安装位置/私有/ tmp / make_tmp / profiles / openhotel /...

    1  我可以使用自制侵略降级到Drush 5.x吗?  ( Can i downgrade to drush 5 x using homebrew ) 
    我使用 brew install drush 安装了最新的稳定版本(6.1),当我需要5.x分支时。 github问题表示苏打5.x包装是为自制的,但我不确定如何安装它。 ...

    0  为什么“疏浚CC所有”失败,“未定义函数User_load()”  ( Why is drush cc all failing with undefined function user load ) 
    更新我的Drupal测试服务器以具有新的数据库和代码的新副本和从生产系统中,"疏浚CC全部" 将失败,消息说 php致命错误:调用undefined函数user_load()在/usr/share/pear/drush/includes/drupal.inc上,在线138 我正在使用drupal 7.25系统...

    1  什么是aegir make_working_copy scm选项意味着什么?  ( What is the aegir make working copy scm option mean ) 
    如果创建平台并选择保留工作副本,这是否启动了.git克隆,即来自CLI的AEGIR用户可以更新和合并分支机构? 创建一个新平台: 润发使选项: normal - 丢弃SCM文件 工作副本 - 保留SCM文件 工作副本目录在哪里? ...

    2  如何使用毛发将多路或多路rsync设置为?  ( How to setup multisite to multisite rsync with drush ) 
    我尝试在多站点设置(本地)和多站点(阶段)之间rsync。如果我运行同步,它将将所有站点复制到DEV到阶段,但我只是希望将当前网站同步。 $drush rsync @dev @stage 我的Drush别名文件位于〜/ .drush / example.aliases.drushrc.php 中 $al...

    2  “fwrite():提供的参数不是有效的流资源”  ( Fwrite supplied argument is not a valid stream resource ) 
    醉酒抛出错误 "通知:使用未定义的常量stderr - 假设'stderr' 在 /kunden/192766_10587/bin/drush/includes/drush.inc 在线 1668 警告:fwrite():提供的参数 不是有效的流资源 /kunden/192766_105...

    0  自定义字段值未使用功能导入  ( Custom field values are not importing with features ) 
    我想在特征中导出示例数据(节点)为其他人启动我开发的一些可重用模块。示例数据包含具有自定义字段的节点。问题是,虽然节点和默认字段值(标题,正文)导入自定义字段的值。我是新功能。我一定要做错了什么。 对于示例数据,我已选择检测到的节点,字段基础,现场实例和依赖项的其余部分,但这不会导出/导入自定义字段值。我猜我必须选择...

    0  如何运行自定义命令通过sudo运行醉酒cron?  ( How to run custom command running drush cron via sudo ) 
    Drush Cron的文档说: 您应该设置crontab以运行Cron任务作为运行Web服务器的同一用户;例如,如果您运行WebServer作为用户www-data: 我写了一个wrapper drush命令来做到这一点。在我的Drush_hook_command中,我打电话给/ p> system('s...

    1  某些疏士命令不可用  ( Certain drush commands not available ) 
    我不是新手使用毛发,但我正在研究一个"遗留" 安装,我有一种感觉尚未设置正确。 这是 drush 输出的相关(我的目的)部分。我可以看到我正在尝试使用列出的命令。 sql命令:(SQL)SQL-CLI(SQLC)打开SQL命令行 使用Drupal凭据的界面。 sql-connect 用于连接到DB的字符...

    0  导出内容时,Drush命令异常终止  ( Drush command terminated abnormally when exporting content ) 
    我已经安装了节点导出模块,并尝试将类型故事的所有内容导出到XML文件,使用: root@pc:/path/to/drupal# drush node-export-export --type=story --file=xstory --format=xml 但我得到 login_process.mo...

    1  XAMPP上的DRUSH存档 - 转储数据库转储失败  ( Drush archive dump database dump failed on xampp ) 
    我想在另一台机器中导入我的本地Drupal站点。这是我从Drupal根文件夹中跑的是我的网站归档 drush archive-dump --destination=mysite.com.tar.gz 几秒钟后,它只是在此消息之后停止 Database dump failed. 我看到mysite....

    7  在尝试运行醉酒时“:没有这样的文件或目录”  ( When attempting to run drush no such file or directory ) 
    我一整天都在抨击墙上,试图弄清楚为什么醉酒突然停止工作。 我通过作曲家重新安装,尝试了不同的版本,总是相同的错误。 如果我键入 which drush i get /home/user/.composer/vendor/bin/drush 是正确的。 如果我键入 sh -vx drush 以尝试调试脚本正在发生的...

    14  “醉汉CC All`命令需要太久,我该怎么办?  ( Drush cc all command takes too long time what can i do ) 
    在我的一个地方 drush cc all 需要超过4分钟运行。网站DB是几个GB。但是,我看不出明确的原因,为什么它需要太长。我该怎么办才能找到瓶颈? ...

    0  “你的命令行PHP安装太旧了”但它不是?  ( Your command line php installation is too old but its not ) 
    我试图在它给我以下错误时安装醉酒版本7.x-5.9(每当我尝试使用drush命令时): 您的命令行PHP安装太旧了。醉酒需要[错误] 最少php 5.3.0。要禁止此检查,请设置环境变量 drush_no_min_php = 1 我的hostmonster信息: Apache版本2.2.26. PHP 5.4.24...

    1  Drush SQL-Sync错误:无法为Target @ MySite.local找到数据项记录  ( Drush sql sync error no databse record could found for target mysite local ) 
    我试图将生产数据库同步到本地环境。当我沿着以下方式运行: drush sql-sync @mysite.prod @mysite.local --source-dump /path/to/dump --target-dump /path-to-dump --create-db --no-cache -y 我...

    2  润滑使能模块和所有子模块  ( Drush enable a module and all its submodules ) 
    例如,当我启用 coder 模块时,我也希望启用 998876662 , coder_sniffer 和 coder_upgrade 模块。 ...

    0  使用自更新升级Windows下的疏呼  ( Upgrading drush under windows using self update ) 
    我在使用msi上安装了W / XP工作站的醉酒,并希望升级它。 我尝试过使用 drush self-update ,但它给出的建议似乎对UNIX安装似乎比Windows更多。 最好的建议看起来像是醉酒dl / path / to / drush,但我不是100%确定/ path / to / drush将在w / x...




    © 2021 it.wenda123.org All Rights Reserved. 问答之家 版权所有


    Licensed under cc by-sa 3.0 with attribution required.