解决drush PDOException: SQLSTATE[HY000] [2002]问题的办法分析

PHP中文网
发布: 2017-04-01 14:27:01
原创
3436人浏览过

今天在mac os中安装drush时遇到一个错误。

Drush command terminated abnormally due to an unrecoverable error. [error] 
<h1>Additional uncaught exception thrown while handling exception.</h1> 
<h2>Original</h2> 
<p>PDOException: SQLSTATE[HY000] [2002] No such file or directory in drupal_is_denied() 
(line 1915 of /Applications/rubystack/apps/drupal/htdocs/includes/bootstrap.inc).</p> 
<h2>Additional</h2> 
<p>PDOException: SQLSTATE[HY000] [2002] No such file or directory in system_list() 
(line 165 of /Applications/rubystack/apps/drupal/htdocs/includes/module.inc).</p><hr />
Process finished with exit code 1 at 17:04:06. 
Execution time: 221 ms.
登录后复制

这个问题错误主要时PDOException: SQLSTATE[HY000] [2002]来自MySQL连接上。

解决方法

在Drupal的默认settings.php文件中加入mysql 加入unix_socket。

array (
'database' => 'demo_drupal',
'username' => 'root',
'password' => '',
'host' => 'localhost',
'port' => '3309',
'unix_socket' => '/Applications/rubystack/mysql/tmp/mysql.sock',
'driver' => 'mysql',
'prefix' => '',
)
登录后复制

检查drush是否正常工作,只需输入drush status来读取信息正常,就说明安装成功了。

如下演示:

讯飞智作-讯飞配音
讯飞智作-讯飞配音

讯飞智作是一款集AI配音、虚拟人视频生成、PPT生成视频、虚拟人定制等多功能的AI音视频生产平台。已广泛应用于媒体、教育、短视频等领域。

讯飞智作-讯飞配音 67
查看详情 讯飞智作-讯飞配音
lixideMacBook-Pro:htdocs lixi$ /Users/lixi/drush/drush status 
Drupal version                  :  7.25 
Site URI                        :  http://default 
Database driver                 :  mysql 
Database username               :  root 
Database name                   :  demo_drupal 
Database                        :  Connected 
Drupal bootstrap                :  Successful 
Drupal user                     : 
Default theme                   :  bartik 
Administration theme            :  seven 
PHP executable                  :  /usr/bin/php 
PHP configuration               : 
PHP OS                          :  Darwin 
Drush version                   :  7.0-dev 
Drush configuration             : 
Drush alias files               : 
Drupal root                     :  /Applications/rubystack/apps/drupal/htdocs 
Site path                       :  sites/default 
File directory path             :  sites/default/files 
Temporary file directory path   :  /Applications/rubystack/php/tmp
登录后复制

 Drush 升级 Drupal

使用drush up命令来升级drupal。

lixideMacBook-Pro:htdocs lixi$ /Users/lixi/drush/drush up 
Name Installed Version Proposed version Message 
Drupal 7.25 7.26 SECURITY UPDATE available
Update information last refreshed: Sun, 01/19/2014 – 13:58 
Code updates will be made to drupal core. 
WARNING: Updating core will discard any modifications made to Drupal core files, 
most noteworthy among these are .htaccess and robots.txt. 
If you have made any modifications to these files, 
please back them up before updating so that you can re-create your modifications in the 
updated version of the file. 
Note: Updating core can potentially break your site. 
It is NOT recommended to update production sites without prior testing.
Do you really want to continue? (y/n): y 
Project drupal was updated successfully. Installed version is now 7.26. 
Backups were saved into the directory [ok] 
/Users/lixi/drush-backups/bitnami_drupal7/20140120095445/drupal. 
Taxonomy 7011 Drop unpublished nodes from the index. 
Do you wish to run all pending updates? (y/n): y 
Performed update: taxonomy_update_7011 [ok] 
‘all’ cache was cleared. [success] 
Finished performing updates. [ok]
登录后复制

 以上就是解决drush PDOException: SQLSTATE[HY000] [2002]问题的办法分析的内容,更多相关内容请关注PHP中文网(www.php.cn)!

最佳 Windows 性能的顶级免费优化软件
最佳 Windows 性能的顶级免费优化软件

每个人都需要一台速度更快、更稳定的 PC。随着时间的推移,垃圾文件、旧注册表数据和不必要的后台进程会占用资源并降低性能。幸运的是,许多工具可以让 Windows 保持平稳运行。

下载
来源:php中文网
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn
作者最新文章
最新问题
开源免费商场系统广告
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责申明 举报中心 意见反馈 讲师合作 广告合作 最新更新 English
php中文网:公益在线php培训,帮助PHP学习者快速成长!
关注服务号 技术交流群
PHP中文网订阅号
每天精选资源文章推送
PHP中文网APP
随时随地碎片化学习

Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号