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

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

问题描述

我正在尝试首次设置Drush.我正在使用Mamp和Mountain Lion.当我在终端中输入'drush'时,我会看到命令列表,因此看来可以安装好了.

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.

我已经更改了MAMP中的默认Web目录文件夹.我在Web目录的文件夹中有许多Drupal站点.因此,一个网站的网址是http://localhost:8888/omega/omegav3/,另一个网站的网址是http://localhost:8888/omega/omegav4/

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/

通过导航到终端中的站点文件夹,我可以运行Drush命令,但是出现错误.当我下载Views时,确实会将模块正确下载到我的sites/all/modules文件夹中,但是它给了我一些错误.当我尝试启用该模块时,它给我带来了更多错误,并且没有启用该模块.

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$ 

Drush和MySQL似乎是一个问题,但我不知道如何解决此问题.我对命令行非常陌生,我之前从未安装过Drush之类的东西,因此我真的很挣扎.

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.

推荐答案

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

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.

线 PDO::__construct(): [2002] No such file or directory (trying to connect via [warning] unix:///var/mysql/mysql.sock) environment.inc:523全部说明.

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.

默认情况下,如MAMP启动页面所述,MAMP默认在/Applications/MAMP/tmp/mysql/mysql.sock中创建MySQL套接字.但是Drush希望套接字位于var/mysql/mysql.sock.

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. 停止所有MAMP服务器.编辑文件/Applications/MAMP/bin/startMysql.sh, 将--socket=/Applications/MAMP/tmp/mysql/mysql.sock更改为--socket=/var/mysql/mysql.sock.并且不要忘记也编辑stopMysql.sh.这告诉MAMP在下次启动Mysql服务器时将套接字存储在其他位置.

  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.

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

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.

祝你好运!

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

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