Salt Bridge

MySQL 初期設定

管理者パスワード設定を試みるが、さっそく拒否された。

# 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)

さっきと挙動が変わったが、次は何をすればいいんだろう。
17:29 : パソコントラックバック(2)  コメント(4)
MySQLとeRubyを使っていて
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 | [編集]

MySQLとeRubyユーザーなのですね。こんな僻地にあるメモですが、もしも何かのお役に立てたのでしたら光栄です。
今のところ特に困ってはいませんが、もし今後何かあったら参考にさせていただきます。コメントありがとうございました。

2006/01/23(月) 02:43:22 | Jironさんへ │ URL | [編集]

MySQL-devel 入れてプロセス再起動すればおこkぽいですょ

2006/07/30(日) 21:49:06 | とおりすがりん │ URL | [編集]

コメントありがとうございます。今度また同様なトラブルに遭遇したら試してみたいと思います。

2006/07/30(日) 23:17:26 | とおりすがりさんへ │ URL | [編集]

コメントの投稿







 管理者にだけ表示を許可

トラックバック

この記事のトラックバックURL

macportsを使ってPHP5,mysql5,apache2,(postgresql)を導入して自宅のPCでセットアップしてみた。 これだけできればsymfonyを導入するのはもう簡単なので。 手順に従ってやれば1日もかからずあっとゆう間にできるものなのだが、プログラマーの世界に入って3ヶ月しか経って

2008/10/29(水) 01:05:53 | TamaCの開発日誌

こんな経験はないだろうか。 家のエアコン、電気コンロ、電子レンジを同時に動かして...

2008/01/17(木) 01:52:55 | soogle webニュース