Drush 无法在 MAMP 上连接到 MySQL? [英] Drush cannot connect to MySQL on MAMP?

查看:30
本文介绍了Drush 无法在 MAMP 上连接到 MySQL?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是第一次尝试设置 Drush.我使用 Mamp 和 Mountain Lion.当我在终端中输入drush"时,我会得到一个命令列表,所以它似乎安装好了.

我已经更改了 MAMP 中的默认 Web 目录文件夹.我在 web 目录中的文件夹中有许多 Drupal 站点.所以一个站点的 url 是 http://localhost:8888/omega/omegav3/ 而另一个是 http://localhost:8888/omega/omegav4/>

通过导航到终端中的站点文件夹,我可以运行 Drush 命令,但是我收到错误消息.当我下载视图时,它确实将模块正确下载到我的站点/所有/模块文件夹,但是它给了我一些错误.当我尝试启用该模块时,它会给我更多错误并且不启用该模块.

unknown:omegav3 MYUSERNAME$ cd/Users/MYUSERNAME/Dropbox/sites/omega/omegav3未知:omegav3 MYUSERNAME$ drush dl 视图PDO::__construct(): [2002] 没有这样的文件或目录(试图通过 [警告] 连接unix:///var/mysql/mysql.sock) environment.inc:523项目视图 (7.x-3.7) 下载到站点/所有/模块/视图.[成功]项目视图包含 2 个模块:views、views_ui.未知:omegav3 MYUSERNAME$未知:omegav3 MYUSERNAME$ 浏览视图PDO::__construct(): [2002] 没有这样的文件或目录(试图通过 [警告] 连接unix:///var/mysql/mysql.sock) environment.inc:523命令 pm-enable 需要更高的引导程序级别才能运行 - 您需要调用 [error]从功能更强大的 Drupal 环境 drush 运行此命令.无法执行 drush 命令en views".[错误]Drush 无法启动(引导)Drupal 数据库.[错误]提示:这可能发生在 Drush 尝试执行以下操作时:* 引导一个尚未安装或没有配置的站点数据库.在这种情况下,您可以通过以下方式选择具有工作数据库设置的另一个站点在命令行上指定要与 --uri 参数一起使用的 URI.见`drush主题 docs-aliases` 了解详情.* 通过套接字连接数据库.可能是socket文件错误或者php-cli可能无法在被监禁的外壳中访问它.见 http://drupal.org/node/1428638细节.Drush 试图连接到:Drupal 版本:7.23站点 URI : http://default数据库驱动:mysql数据库用户名:root数据库名称:omegav3默认主题:花环行政主题:花环PHP 可执行文件:/usr/bin/phpPHP配置:PHP 操作系统:达尔文刷版本:6.1.0刷配置:Drush别名文件:Drupal 根:/Users/MYUSERNAME/Dropbox/sites/omega/omegav3站点路径:站点/默认文件目录路径:sites/default/files未知:omegav3 MYUSERNAME$

这似乎是 Drush 和 MySQL 的一个问题,但我不知道如何解决这个问题.我对命令行很陌生,我以前从未安装过像 Drush 这样的东西,所以我真的很挣扎.

解决方案

先说我对 Drush 一点都不熟悉.但是从 MAMP 的角度来看,我想我知道这里发生了什么.

线PDO::__construct(): [2002] 没有那个文件或目录(试图通过 [警告] 连接unix:///var/mysql/mysql.sock) environment.inc:523 说明了一切.

默认情况下,MAMP 在 /Applications/MAMP/tmp/mysql/mysql.sock 中创建 MySQL 套接字,如 MAMP 启动页面所述.然而,Drush 期待 var/mysql/mysql.sock 的套接字.

嗯,有两种方法可以解决这个问题.

  1. 停止所有 MAMP 服务器.编辑文件 /Applications/MAMP/bin/startMysql.sh,将 --socket=/Applications/MAMP/tmp/mysql/mysql.sock 更改为 --socket=/var/mysql/mysql.sock.并且不要忘记编辑 stopMysql.sh.这告诉 MAMP 下次启动 Mysql 服务器时将套接字存储在别处.

  2. 创建从 /var/mysql/mysql.sock/Applications/MAMP/tmp/mysql/mysql.sock 的符号链接,参见 帖子以获取有关符号链接的更多信息.需要运行 MAMP 才能执行此操作,因为套接字文件是动态创建的.

祝你好运!

Im trying to set Drush up for the first time. Im using Mamp and Mountain Lion. When I type 'drush' into the terminal I get a list of commands so it seems to be installed up OK.

Ive changed the default web directory folder in MAMP. I have many Drupal sites within folders within the web directory. So the url for one site is http://localhost:8888/omega/omegav3/ and another is http://localhost:8888/omega/omegav4/

By navigating to the site folder in the terminal I can then run a Drush command, however I get errors. When I download Views it does download the module to my sites/all/modules folder correctly, however it gives me some errors. When I try and enable the module it gives me more errors and doesn't enable the module.

unknown:omegav3 MYUSERNAME$ cd /Users/MYUSERNAME/Dropbox/sites/omega/omegav3 
unknown:omegav3 MYUSERNAME$ drush dl views
PDO::__construct(): [2002] No such file or directory (trying to connect via           [warning]
unix:///var/mysql/mysql.sock) environment.inc:523
Project views (7.x-3.7) downloaded to sites/all/modules/views.                        [success]
Project views contains 2 modules: views, views_ui.
unknown:omegav3 MYUSERNAME$ 
unknown:omegav3 MYUSERNAME$ drush en views
PDO::__construct(): [2002] No such file or directory (trying to connect via           [warning]
unix:///var/mysql/mysql.sock) environment.inc:523
Command pm-enable needs a higher bootstrap level to run - you will need to invoke     [error]
drush from a more functional Drupal environment to run this command.
The drush command 'en views' could not be executed.                                   [error]
Drush was not able to start (bootstrap) the Drupal database.                          [error]
Hint: This may occur when Drush is trying to:
 * 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.

Drush was attempting to connect to: 
 Drupal version         :  7.23                                             
 Site URI               :  http://default                                   
 Database driver        :  mysql                                            
 Database username      :  root                                             
 Database name          :  omegav3                                          
 Default theme          :  garland                                          
 Administration theme   :  garland                                          
 PHP executable         :  /usr/bin/php                                     
 PHP configuration      :                                                   
 PHP OS                 :  Darwin                                           
 Drush version          :  6.1.0                                            
 Drush configuration    :                                                   
 Drush alias files      :                                                   
 Drupal root            :  /Users/MYUSERNAME/Dropbox/sites/omega/omegav3 
 Site path              :  sites/default                                    
 File directory path    :  sites/default/files                              


unknown:omegav3 MYUSERNAME$ 

It seems like an issue with Drush and MySQL but ive no idea how to fix this. Im very new to the command line and ive never installed anything like Drush before so im really struggling.

解决方案

Lets start with saying that i am not familiar with Drush at all. But looking at this from a MAMP perspective i think i know what is going on here.

The line PDO::__construct(): [2002] No such file or directory (trying to connect via [warning] unix:///var/mysql/mysql.sock) environment.inc:523 says it all.

By default MAMP is creating the MySQL socket in /Applications/MAMP/tmp/mysql/mysql.sock as stated on the MAMP launch page. However Drush is expecting the socket at var/mysql/mysql.sock.

Well there are two ways to fix this.

  1. Stop all MAMP servers. Edit the file /Applications/MAMP/bin/startMysql.sh, change --socket=/Applications/MAMP/tmp/mysql/mysql.sock into --socket=/var/mysql/mysql.sock. And don't forget to edit stopMysql.sh as well. This tells MAMP to store the socket elsewhere the next time it boots up the Mysql server.

  2. Create a symlink from /var/mysql/mysql.sock to /Applications/MAMP/tmp/mysql/mysql.sock see this post for more info on symlinks. MAMP will need to be running for you to do this, as the socket file is created dynamically.

Good luck!

这篇关于Drush 无法在 MAMP 上连接到 MySQL?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆