忍者ブログ
自分なりの目線で情報を発信します。
×

[PR]上記の広告は3ヶ月以上新規記事投稿のないブログに表示されています。新しい記事を書く事で広告が消えます。

MySQLをyumでインストールした直後にオリジナルのmy.cnfをリネームして、
新しいmy.cnfを適当に作成すると、サーバーの起動に失敗しました。
サーバーの起動を成功させるまでのメモです。
[root@localhost etc]# /etc/rc.d/init.d/mysqld restart
Stopping MySQL:                                            [FAILED]
touch: cannot touch `/var/log/mysql/error.log': No such file or directory
chown: cannot access `/var/log/mysql/error.log': No such file or directory
chmod: cannot access `/var/log/mysql/error.log': No such file or directory
Initializing MySQL database:  Installing MySQL system tables...
/usr/libexec/mysqld: File '/var/log/mysql/bin-index.log' not found (Errcode: 2)
121115 14:58:33 [ERROR] Aborting

121115 14:58:33 [Note] /usr/libexec/mysqld: Shutdown complete


Installation of system tables failed!  Examine the logs in
/var/lib/mysql for more information.

You can try to start the mysqld daemon with:

    shell> /usr/libexec/mysqld --skip-grant &

and use the command line tool /usr/bin/mysql
to connect to the mysql database and look at the grant tables:

    shell> /usr/bin/mysql -u root mysql
    mysql> show tables

Try 'mysqld --help' if you have problems with paths.  Using --log
gives you a log in /var/lib/mysql 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 mailing us!  And remember, if
you do mail us, you MUST use the /usr/bin/mysqlbug script!

                                                           [FAILED]
 
MySQLサーバーの初回起動前には、mysql_install_dbの実行が必要ですね。
ということで実行するも失敗。
調べてみると、my.cnfに問題があるらしい。
 
ここを参考にさせてもらいました。
 
ということで、my.cnfを元に戻してmysql_install_dbを実行。
[root@localhost etc]# cd /etc
[root@localhost etc]# mv my.cnf my.cnf.new
[root@localhost etc]# mv my.cnf.org my.cnf
[root@localhost etc]#
[root@localhost etc]# 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:

/usr/bin/mysqladmin -u root password 'new-password'
/usr/bin/mysqladmin -u root -h localhost password 'new-password'

Alternatively you can run:
/usr/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 /usr ; /usr/bin/mysqld_safe &

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

Please report any problems with the /usr/bin/mysqlbug script!

[root@localhost etc]#
 
mysql_install_db に成功。
MySQLサーバーも起動してみる。
[root@localhost etc]# /etc/rc.d/init.d/mysqld start
Starting MySQL:                                            [  OK  ]
[root@localhost etc]#
サーバーの起動にも成功。
それでは、my.cnfを新しいものに再度修正して、サーバーを再起動。
 
[root@localhost etc]# /etc/rc.d/init.d/mysqld stop
Stopping MySQL:                                            [  OK  ]
[root@localhost etc]#
[root@localhost etc]# mv my.cnf my.cnf.org
[root@localhost etc]# mv my.cnf.new my.cnf
[root@localhost etc]# /etc/rc.d/init.d/mysqld start
touch: cannot touch `/var/log/mysql/error.log': No such file or directory
chown: cannot access `/var/log/mysql/error.log': No such file or directory
chmod: cannot access `/var/log/mysql/error.log': No such file or directory
MySQL Daemon failed to start.
Starting MySQL:                                            [FAILED]
[root@localhost etc]#

サーバー起動失敗。
/var/log/mysql/error.log が無いと怒っているので、新旧のmy.cnfを見比べてみると、
 
■新しいmy.cnfの内容の一部
[mysqld_safe]
log-error=/var/log/mysql/error.log
 
■古いmy.cnfの内容の一部
[mysqld_safe]
log-error=/var/log/mysqld.log
 
ログディレクトリが違う。
サーバー起動時に自動的にディレクトリ作成までしてくれるほど、さすがに都合良くはないか。
ということで、ログディレクトリを手動で作って、サーバー再起動。
[root@localhost etc]# mkdir /var/log/mysql
[root@localhost etc]# ls -l /var/log/mysql
total 0
[root@localhost etc]# ls -ld /var/log/mysql
drwxrwxr-x 2 root root 4096 Nov 15 16:33 /var/log/mysql
[root@localhost etc]# chown mysql:mysql /var/log/mysql
[root@localhost etc]# ls -ld /var/log/mysql
drwxrwxr-x 2 mysql mysql 4096 Nov 15 16:33 /var/log/mysql
[root@localhost etc]#
[root@localhost etc]# /etc/rc.d/init.d/mysqld start
MySQL Daemon failed to start.
Starting MySQL:                                            [FAILED]
[root@localhost etc]#

ログディレクトリが無いとは言わなくなったけど、再起動には失敗。
エラーログを見てみると・・・
[root@localhost etc]# vi /var/log/mysql/error.log
-------- ログの内容 --------
121115 16:34:59 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql
121115 16:34:59 [Note] Plugin 'ndbcluster' is disabled.
InnoDB: Error: log file ./ib_logfile0 is of different size 0 5242880 bytes
InnoDB: than specified in the .cnf file 0 16777216 bytes!
121115 16:35:00 [ERROR] Plugin 'InnoDB' init function returned error.
121115 16:35:00 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed.
121115 16:35:00 [ERROR] Unknown/unsupported table type: InnoDB
121115 16:35:00 [ERROR] Aborting

121115 16:35:00 [Note] /usr/libexec/mysqld: Shutdown complete

121115 16:35:00 mysqld_safe mysqld from pid file /var/run/mysqld/mysqld.pid ended
--------- /ログの内容 --------
my.cnf で、innodb_log_file_size の値をいじったあとには、必ずInnoDBログファイルを削除しないとエラーになるらしい。
前に起動していたときに作ったログファイルのサイズと、今回定義されたサイズが合わない、ということらしい。
ここを参考にさせてもらいました。
 
ログファイルを消して再起動。
[root@localhost etc]# rm /var/lib/mysql/ib
ibdata1      ib_logfile0  ib_logfile1 
[root@localhost etc]# rm /var/lib/mysql/ib*
rm: remove regular file `/var/lib/mysql/ibdata1'? y
rm: remove regular file `/var/lib/mysql/ib_logfile0'? y
rm: remove regular file `/var/lib/mysql/ib_logfile1'? y
[root@localhost etc]# /etc/rc.d/init.d/mysqld start
Starting MySQL:                                            [  OK  ]
[root@localhost etc]#
 
起動成功!
 
 
PR
この記事にコメントする
お名前
タイトル
文字色
メールアドレス
URL
コメント
パスワード   Vodafone絵文字 i-mode絵文字 Ezweb絵文字
お知らせ
プロフィール
HN:
shusatoo
性別:
男性
自己紹介:
基本PHP。JavaScriptちょっとだけ。Javaをほんの少し。
おすすめ本
最新コメント
[10/09 shusatoo]
[10/09 misney]
最新トラックバック
カレンダー
02 2024/03 04
S M T W T F S
1 2
3 4 5 6 7 8 9
10 11 12 13 14 15 16
17 18 19 20 21 22 23
24 25 26 27 28 29 30
31
ブログ内検索
カウンター
アク解アナライズ
バーコード
ビジター

Copyright © [ 開発メモるアル ] All rights reserved.
Special Template : 忍者ブログ de テンプレート
Special Thanks : 忍者ブログ
Commercial message : [PR]