如何让MySql在AWS上使用默认的sock?

时间:2013-12-30 19:13:38

标签: mysql amazon-web-services amazon-ec2

我正在开发一个需要MySql来使用默认袜子的项目。该项目托管在AWS EC2节点上。

目前我有这个错误:

$ mysql
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)

mysqld正在运行。这是证据:

$ ps aux | grep mysql
root      4063  0.0  0.0  66116  1356 ?        S    Dec18   0:00 /bin/sh /var/lib/data/opt/sugarcrm-6.4.0/mysql/bin/mysqld_safe --defaults-file=/var/lib/data/opt/sugarcrm-6.4.0/mysql/my.cnf --port=3306 --socket=/var/lib/data/opt/sugarcrm-6.4.0/mysql/tmp/mysql.sock --datadir=/var/lib/data/opt/sugarcrm-6.4.0/mysql/data --log-error=/var/lib/data/opt/sugarcrm-6.4.0/mysql/data/mysqld.log --pid-file=/var/lib/data/opt/sugarcrm-6.4.0/mysql/data/dev-play02.pid --lower-case-table-names=1
mysql     4311  0.0  0.9 319632 36976 ?        Sl   Dec18   0:00 /var/lib/data/opt/sugarcrm-6.4.0/mysql/bin/mysqld.bin --defaults-file=/var/lib/data/opt/sugarcrm-6.4.0/mysql/my.cnf --basedir=/var/lib/data/opt/sugarcrm-6.4.0/mysql --datadir=/var/lib/data/opt/sugarcrm-6.4.0/mysql/data --plugin-dir=/var/lib/data/opt/sugarcrm-6.4.0/mysql/lib/plugin --user=mysql --lower-case-table-names=1 --log-error=/var/lib/data/opt/sugarcrm-6.4.0/mysql/data/mysqld.log --pid-file=/var/lib/data/opt/sugarcrm-6.4.0/mysql/data/dev-play02.pid --socket=/var/lib/data/opt/sugarcrm-6.4.0/mysql/tmp/mysql.sock --port=3306
16777227 20011  0.0  0.0  61228   772 pts/0    S+   10:59   0:00 grep mysql

上面的ps输出是我在登录EC2节点时默认获得的。如您所见,袜子是自定义的,如参数--socket=/var/lib/data/opt/sugarcrm-6.4.0/mysql/tmp/mysql.sock中所示。

所以,我的问题是:当我登录节点时,如何让MySql使用默认的袜子/var/lib/mysql/mysql.sock?非常感谢你。

顺便说一下,我相信EC2节点正在运行RedHat linux。

更新 根据nrathaus的建议,my.cnf文件可能是嫌疑人。所以,这是EC2节点上/etc/my.cnf的完整内容:

[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
user=mysql
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0

# Semisynchronous Replication
# http://dev.mysql.com/doc/refman/5.5/en/replication-semisync.html
# uncomment next line on MASTER
;plugin-load=rpl_semi_sync_master=semisync_master.so
# uncomment next line on SLAVE
;plugin-load=rpl_semi_sync_slave=semisync_slave.so

# Others options for Semisynchronous Replication
;rpl_semi_sync_master_enabled=1
;rpl_semi_sync_master_timeout=10
;rpl_semi_sync_slave_enabled=1

# http://dev.mysql.com/doc/refman/5.5/en/performance-schema.html
;performance_schema


[mysqld_safe]
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid

1 个答案:

答案 0 :(得分:1)

打开/etc/mysql/my.cnf,找到socket=的引用,并确保它们都指向同一个地方。

在您的情况下,应该改为:

socket=/var/lib/mysql/mysql.sock 

socket=/var/lib/data/opt/sugarcrm-6.4.0/mysql