2005'05.17
# mysql -uroot
ERROR 2002: Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)
では、MySQL インストール時に出たメッセージに従ってみることにしよう。。。
PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
To do so, start the server, then issue the following commands:
/usr/bin/mysqladmin -u root password 'new-password'
/usr/bin/mysqladmin -u root -h localhost.localdomain password 'new-password'
See the manual for more instructions.
一つ目のコマンドを実行。OK
二つ目のコマンドを実行。すると
/usr/bin/mysqladmin: connect to server at 'localhost.localdomain' failed
error: 'Access denied for user: 'root@localhost' (Using password: NO)'
むむ?意味分からん。
http://dev.mysql.com/doc/mysql/ja/post-installation.html
を参考にトライしてみよう。まず、、
「必要に応じて、」と書いてあるけど、必要なのかどうか分からない。えーと、、、「一般に、mysql_install_db は、初めて MySQL をインストールしたときにのみ実行する必要がある」だから、今回は必要あるわけだ。よし。
mysqld サーバを起動して、MySQL 権限テーブルを初期化する。試してみよう。
# /usr/bin/mysql_install_db
Installing all prepared tables
050517 13:07:40 /usr/sbin/mysqld: Shutdown Complete
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:
/usr/bin/mysqladmin -u root password 'new-password'
/usr/bin/mysqladmin -u root -h localhost.localdomain password 'new-password'
See the manual for more instructions.
NOTE: If you are upgrading from a MySQL <= 3.22.10 you should run
the /usr/bin/mysql_fix_privilege_tables. Otherwise you will not be
able to use the new GRANT command!
You can start the MySQL daemon with:
cd / ; /usr/bin/mysqld_safe &
You can test the MySQL daemon with the benchmarks in the 'sql-bench' directory:
cd sql-bench ; perl run-all-tests
Please report any problems with the /usr/bin/mysqlbug script!
The latest information about MySQL is available on the web at
http://www.mysql.com
Support MySQL by buying support/licenses at https://order.mysql.com
なんかいろいろ出てきたけど、エラーではなさそうだ。
MySQLデーモンの起動。失敗。
# /usr/bin/mysqld_safe
Starting mysqld-max daemon with databases from /var/lib/mysql
STOPPING server from pid file /var/lib/mysql/localhost.localdomain.pid
050517 13:15:25 mysqld ended
これはおそらく、上述の
/usr/bin/mysqladmin -u root -h localhost.localdomain password 'new-password'
に失敗したままだから、だろうな。これを解決する必要あり。
# mysql
ERROR 2002: Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)
まずこいつを解決する必要があるな。見てみたら、/var/lib/mysql/mysql.sock というファイルそのものが存在しなかった。
解決法は、ここにありそうだ↓
http://www.hi-ho.ne.jp/tsumiki/book_sup2.html
ここによると、/etc/my.conf をいじるといいらしいが。。。
そんなファイル、存在しないぞ??
なんらかの理由でソケットファイルが削除されている場合、MySQLサーバーを一旦シャットダウンして再起動すると復元されるそうな。するってーと、
こういうことですか?
# mysqladmin shutdown
mysqladmin: connect to server at 'localhost' failed
error: 'Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)'
Check that mysqld is running and that the socket: '/var/lib/mysql/mysql.sock' exists!
あかんやん。ほな、
# mysqladmin --host=(IPアドレス) shutdown
mysqladmin: connect to server at 'IPアドレス' failed
error: 'Host '自分のサーバーマシン' is not allowed to connect to this MySQL server'
あかん。うーん。。。
# /usr/bin/mysqladmin -u root -h (IPアドレス) password (パスワード)
/usr/bin/mysqladmin: connect to server at 'IPアドレス' failed
error: 'Host '自分のサーバーマシン' is not allowed to connect to this MySQL server'
さっきと同じエラーが出たな。。。
IPアドレスの部分を"localhost"にしてみると、
# /usr/bin/mysqladmin -u root -h localhost password (パスワード)
/usr/bin/mysqladmin: connect to server at 'localhost' failed
error: 'Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)'
Check that mysqld is running and that the socket: '/var/lib/mysql/mysql.sock' exists!
む?どういうこと?
/var/lib/mysql/mysql.sockってのも、存在しないし。
# /usr/bin/mysqladmin -u root -h localhost.localdomain password (パスワード)
/usr/bin/mysqladmin: connect to server at 'localhost.localdomain' failed
error: 'Access denied for user: 'root@localhost' (Using password: NO)'
わけわからーん。
Vine Linux 3.1 を再起動してから確認すると、
/var/lib/mysql/mysql.sock が存在していた。
/etc/my.conf は今だ存在せず。
# mysql -uroot
ERROR 1045: Access denied for user: 'root@localhost' (Using password: NO)
さっきと挙動が変わったが、次は何をすればいいんだろう。
To do so, start the server, then issue the following commands:
/usr/bin/mysqladmin -u root password 'new-password'
/usr/bin/mysqladmin -u root -h localhost.localdomain password 'new-password'
See the manual for more instructions.
一つ目のコマンドを実行。OK
二つ目のコマンドを実行。すると
/usr/bin/mysqladmin: connect to server at 'localhost.localdomain' failed
error: 'Access denied for user: 'root@localhost' (Using password: NO)'
むむ?意味分からん。
http://dev.mysql.com/doc/mysql/ja/post-installation.html
を参考にトライしてみよう。まず、、
「必要に応じて、」と書いてあるけど、必要なのかどうか分からない。えーと、、、「一般に、mysql_install_db は、初めて MySQL をインストールしたときにのみ実行する必要がある」だから、今回は必要あるわけだ。よし。
mysqld サーバを起動して、MySQL 権限テーブルを初期化する。試してみよう。
# /usr/bin/mysql_install_db
Installing all prepared tables
050517 13:07:40 /usr/sbin/mysqld: Shutdown Complete
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:
/usr/bin/mysqladmin -u root password 'new-password'
/usr/bin/mysqladmin -u root -h localhost.localdomain password 'new-password'
See the manual for more instructions.
NOTE: If you are upgrading from a MySQL <= 3.22.10 you should run
the /usr/bin/mysql_fix_privilege_tables. Otherwise you will not be
able to use the new GRANT command!
You can start the MySQL daemon with:
cd / ; /usr/bin/mysqld_safe &
You can test the MySQL daemon with the benchmarks in the 'sql-bench' directory:
cd sql-bench ; perl run-all-tests
Please report any problems with the /usr/bin/mysqlbug script!
The latest information about MySQL is available on the web at
http://www.mysql.com
Support MySQL by buying support/licenses at https://order.mysql.com
なんかいろいろ出てきたけど、エラーではなさそうだ。
MySQLデーモンの起動。失敗。
# /usr/bin/mysqld_safe
Starting mysqld-max daemon with databases from /var/lib/mysql
STOPPING server from pid file /var/lib/mysql/localhost.localdomain.pid
050517 13:15:25 mysqld ended
これはおそらく、上述の
/usr/bin/mysqladmin -u root -h localhost.localdomain password 'new-password'
に失敗したままだから、だろうな。これを解決する必要あり。
# mysql
ERROR 2002: Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)
まずこいつを解決する必要があるな。見てみたら、/var/lib/mysql/mysql.sock というファイルそのものが存在しなかった。
解決法は、ここにありそうだ↓
http://www.hi-ho.ne.jp/tsumiki/book_sup2.html
ここによると、/etc/my.conf をいじるといいらしいが。。。
そんなファイル、存在しないぞ??
なんらかの理由でソケットファイルが削除されている場合、MySQLサーバーを一旦シャットダウンして再起動すると復元されるそうな。するってーと、
こういうことですか?
# mysqladmin shutdown
mysqladmin: connect to server at 'localhost' failed
error: 'Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)'
Check that mysqld is running and that the socket: '/var/lib/mysql/mysql.sock' exists!
あかんやん。ほな、
# mysqladmin --host=(IPアドレス) shutdown
mysqladmin: connect to server at 'IPアドレス' failed
error: 'Host '自分のサーバーマシン' is not allowed to connect to this MySQL server'
あかん。うーん。。。
# /usr/bin/mysqladmin -u root -h (IPアドレス) password (パスワード)
/usr/bin/mysqladmin: connect to server at 'IPアドレス' failed
error: 'Host '自分のサーバーマシン' is not allowed to connect to this MySQL server'
さっきと同じエラーが出たな。。。
IPアドレスの部分を"localhost"にしてみると、
# /usr/bin/mysqladmin -u root -h localhost password (パスワード)
/usr/bin/mysqladmin: connect to server at 'localhost' failed
error: 'Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)'
Check that mysqld is running and that the socket: '/var/lib/mysql/mysql.sock' exists!
む?どういうこと?
/var/lib/mysql/mysql.sockってのも、存在しないし。
# /usr/bin/mysqladmin -u root -h localhost.localdomain password (パスワード)
/usr/bin/mysqladmin: connect to server at 'localhost.localdomain' failed
error: 'Access denied for user: 'root@localhost' (Using password: NO)'
わけわからーん。
Vine Linux 3.1 を再起動してから確認すると、
/var/lib/mysql/mysql.sock が存在していた。
/etc/my.conf は今だ存在せず。
# mysql -uroot
ERROR 1045: Access denied for user: 'root@localhost' (Using password: NO)
さっきと挙動が変わったが、次は何をすればいいんだろう。


Can't connect to local MySQL server through socket '/tmp/mysql.sock'
というエラーメッセージに悩まされていたら
ここの記事を発見しました。
結論からいうと
/tmpディレクトリにて
ln -s /var/lib/mysql/mysql.sock .
で、mysql.sockのシンボリックリンクを作成したら
あっさり動いてしまいました。
原因はよくわかりませんが・・・
2006/01/22(日) 13:33:04 | Jiron │ URL | [編集]