0

Today I have changed mysql config file and restarted mysql with:

service mysql restart

And saw the following:

Stopping mysql database server: mysqld.
Starting mysql database server: mysqld. Checking for corrupt, not cleanly closed and upgrade needing tables..

After that the mysql service started working, but later I saw errors on my website and realized that InnoDB engine was not started.
In /var/log/daemon.log I saw the following lines:

InnoDB: Error: log file ./ib_logfile0 is of different size 0 5242880 bytes
InnoDB: than specified in the .cnf file 0 67108864 bytes!
[ERROR] Plugin 'InnoDB' init function returned error.
[ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed.

I deleted the log files and restarted mysql, but that's not the question.

The question is:
How can I know there were errors on starting mysql without looking into daemon.log file? Maybe it's possible to setup printing mysql startup errors to stdout?

1
  • The files ib_logfile0 and ib_logfile1 are not log files in the normal sense of the word. They are used for temporarily storing data before it is written to the correct InnoDB files in order to increase throughput and improve response times due to sequential writing. If you delete these files while MySQL is running or after it has crashed you will most likely lose data. This is how to do it safely.
    – Ladadadada
    Commented Mar 10, 2012 at 14:56

2 Answers 2

1

The daemon.log gets filled by syslog. So the only way see what happens in there during a normal startup is to type in another shell

tail -f /varlog/daemon.log

If you want to be warned of bigger issues you can modify the init script. I had a quick look in the mysql init script: /etc/init.d/mysql and found that logger is used to log the errors to /var/log/daemon.err:

# priority can be overriden and "-s" adds output to stderr                      
ERR_LOGGER="logger -p daemon.err -t /etc/init.d/mysql -i"

With adding a "-s" to the second line, the errors will also be logged to stderr.

2
  • But mysql logs not only errors to daemon.log, but all startup comments. And the logger is set up to log to daemon.err, not to daemon.log. So it seems that logging to daemon.log is set up in another place?
    – nightcoder
    Commented Mar 10, 2012 at 20:35
  • Sorry I mixed up daemon.log and daemon.err. I've modified the answer accordingly.
    – Lars Jacob
    Commented Mar 13, 2012 at 20:52
0

Permanently printing error messages to stdout instead of logging them in a file is NOT a good idea for several reasons:

  1. You will lose the error messages after some time especially if there are many lines of output coming quickly.
  2. You will not be able to see the error messages after system reboot.

It may be useful to do so when debugging some issue during daemon startup. This can be done by just executing the process manually without forking. On my system, mysql process will not detach from terminal when I invoke it using sudo mysqld.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .