Ubuntu – Changing MySQL startup timeout ([fail] reported although thesql properly started)

MySQLstartuptimeoutUbuntu

I've created a script to cleanup InnoDB storage engine. Everything works fine except that creating the ib_logfile0 and ib_logfile1 files when innodb_log_file_size is set to 1GB takes a while which causes /etc/init.d/mysql to timeout and report a failure, although in the background MySQL ends up starting normally.

Starting mysql

$ /etc/init.d/mysql start
* Starting MariaDB database server mysqld  [fail] 

Meanwhile in the logs

$ tail -f /var/log/mysql.err
120426 11:19:55  InnoDB: Log file ./ib_logfile0 did not exist: new to be created
InnoDB: Setting log file ./ib_logfile0 size to 1024 MB
InnoDB: Database physically writes the file full: wait...
InnoDB: Progress in MB: 100 200 300 400 500 600 700 800 900 1000
120426 11:20:07  InnoDB: Log file ./ib_logfile1 did not exist: new to be created
InnoDB: Setting log file ./ib_logfile1 size to 1024 MB
InnoDB: Database physically writes the file full: wait...
InnoDB: Progress in MB: 100 200 300 400 500 600 700 800 900 1000
[...]
120426 11:20:24 [Note] /usr/sbin/mysqld: ready for connections.
# Version: '5.5.23-MariaDB-mariadb1~oneiric-log'  socket: '/var/run/mysqld/mysqld.sock'  port: 3306  mariadb.org binary distribution

I am looking for a way to prevent the startup script from timing out. When I look at /etc/init.d/mysql, I can see the ${MYSQLD_STARTUP_TIMEOUT} variable but don't know where it is set. I've also been looking in the documentation for such an option but couldn't find it.

Q1: Can I specify a custom startup timeout as a parameter to /etc/init.d/mysql ?
Q2: What option can I modify to change the server startup timeout in the configuration?

Best Answer

I know this is an old question, but I'm posting in case anyone else is looking for a better/different answer. I've been having a similar problem, but when installing upgrades. Ours takes a long time to start as it is part of a Galera cluster and needs to copy over what it missed while it was down.

To start run:

MYSQLD_STARTUP_TIMEOUT=900 /etc/init.d/mysql start

or on a system with service, like Ubuntu:

sudo MYSQLD_STARTUP_TIMEOUT=900 service mysql start

And in my case, for upgrades call:

sudo MYSQLD_STARTUP_TIMEOUT=900 apt-get dist-upgrade