mysqld.sockがない

% sudo -u _mysql /opt/local/lib/mysql55/bin/mysql_install_db // 初期化
Installing MySQL system tables...
OK
Filling help tables...
OK

To start mysqld at boot time you have to copy
support-files/mysql.server to the right place for your system

PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
To do so, start the server, then issue the following commands:

/opt/local/lib/mysql55/bin/mysqladmin -u root password 'new-password'
/opt/local/lib/mysql55/bin/mysqladmin -u root -h omac-2.local password 'new-password'

Alternatively you can run:
/opt/local/lib/mysql55/bin/mysql_secure_installation

which will also give you the option of removing the test
databases and anonymous user created by default.  This is
strongly recommended for production servers.

See the manual for more instructions.

You can start the MySQL daemon with:
cd /opt/local ; /opt/local/lib/mysql55/bin/mysqld_safe &

You can test the MySQL daemon with mysql-test-run.pl
cd /opt/local/mysql-test ; perl mysql-test-run.pl

Please report any problems at http://bugs.mysql.com/
% /opt/local/lib/mysql55/bin/mysql_secure_installation




NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MySQL
      SERVERS IN PRODUCTION USE!  PLEASE READ EACH STEP CAREFULLY!


In order to log into MySQL to secure it, we'll need the current
password for the root user.  If you've just installed MySQL, and
you haven't set the root password yet, the password will be blank,
so you should just press enter here.

Enter current password for root (enter for none):
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/opt/local/var/run/mysql55/mysqld.sock' (2)
% sudo vim /opt/local/etc/mysql55/my.cnf

!include /opt/local/etc/mysql55/macports-default.cnf

macportsのデフォルトのcnfを読み込まないよう、コメントアウトします。

# Use default MacPorts settings
# !include /opt/local/etc/mysql55/macports-default.cnf

#add
[client]
port= 3306

[mysqld]
port= 3306
$ sudo port load mysql55-server

これで、mysqld.sockが復活するはずです。



参考

Mac でMysqlが立ち上がらなかった話 - UFOのWEB開発記