ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/opt/local/var/run/mysql55/mysqld.sock' (38)

% mysql -u root -p
% ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/opt/local/var/run/mysql55/mysqld.sock' (38)

mysqld.sockはある、が繋がらない。

% sudo -u _mysql /opt/local/lib/mysql55/bin/mysql_install_db
Installing MySQL system tables...
150208 19:05:36 [ERROR] /opt/local/lib/mysql55/bin/mysqld: unknown variable '+ character-set-server=utf8'
150208 19:05:36 [ERROR] Aborting

150208 19:05:36 [Note] /opt/local/lib/mysql55/bin/mysqld: Shutdown complete


Installation of system tables failed!  Examine the logs in
/opt/local/var/db/mysql55 for more information.

You can try to start the mysqld daemon with:

    shell> /opt/local/lib/mysql55/bin/mysqld --skip-grant &

and use the command line tool /opt/local/lib/mysql55/bin/mysql
to connect to the mysql database and look at the grant tables:

    shell> /opt/local/lib/mysql55/bin/mysql -u root mysql
    mysql> show tables

Try 'mysqld --help' if you have problems with paths.  Using --log
gives you a log in /opt/local/var/db/mysql55 that may be helpful.

Please consult the MySQL manual section
'Problems running mysql_install_db', and the manual section that
describes problems on your OS.  Another information source are the
MySQL email archives available at http://lists.mysql.com/.

Please check all of the above before submitting a bug report
at http://bugs.mysql.com/
% sudo vi /opt/local/etc/mysql55/my.cnf

MySQLの設定ファイルmy.cnfを書き換え

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

[mysqld]
port=3306
key_buffer_size=16M
max_allowed_packet=16M
socket = /opt/local/var/run/mysql55/mysqld.sock

[client]
port=3306
socket = /opt/local/var/run/mysql55/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/ 

無事、繋がりました。