MySQL won't start at boot

Hi

In a newly installed freebsd8 box, I did install MySQL from ports, created the system DBs, changed the root passwd and so on. Added the line

Code:
mysql_enable="YES"

to /etc/rc.conf and it worked without a hitch. Left it running without problems.

2 weeks later had to boot the box as I was adding a external HD, and MySQL would not start.
when trying to start from cli all I get is:

Code:
 /usr/local/etc/rc.d]# ./mysql-server start
Starting mysql.
su: Sorry
./mysql-server: WARNING: failed to start mysql

have gotten to the point where I can start using mysqld_safe, but the output from the start script does not confirm it:

Code:
[root@blackbox /usr/local/etc/rc.d]# ./mysql-server status
mysql is not running.
[root@blackbox /usr/local/etc/rc.d]# ./mysql-server rcvar
# mysql
mysql_enable=YES

Can log onto mysql and the process is definitely there:

Code:
[root@blackbox /usr/local/etc/rc.d]# ps waux | grep -i my
root     32562  0.0  0.1  3624  1336   1  I     9:31AM   0:00.03 /bin/sh /usr/local/bin/mysqld_safe
mysql    32682  0.0  1.6 71424 28540   1  I     9:31AM   0:00.31 /usr/local/libexec/mysqld --basedir=/usr/local --datadir=/var/db/m
root     32732  0.0  0.1  3492   984   1  S+    9:35AM   0:00.00 grep -i my
root     31290  0.0  0.0  3284   708   4  I+    8:21AM   0:00.02 tail -f /var/log/mysql/error.log

Kind of stumped right now, as google no longer provides any useful results.
Any pointers appreciated
 
I'm wondering where that su: Sorry message comes from. AFAIK there's no su command used in the mysql rc script.
 
is the mysql user still there? do a # vipw to verify.
Commenting unix user mysql in my 8.0-RELEASE-p2 gives:
Code:
root@smadevnew:~# /usr/local/etc/rc.d/mysql-server onestart
Starting mysql.
su: unknown login: mysql
/usr/local/etc/rc.d/mysql-server: WARNING: failed to start mysql
Not what you get but close.
 
SirDice said:
I'm wondering where that su: Sorry message comes from. AFAIK there's no su command used in the mysql rc script.
it is in /etc/rc.subr, however "su: Sorry" usually means wrong password :\
 
Wow, impressive the celerity of this forum is the fastest I've seen in a while.

User mysql indeed was locked. Unlocked it and mysql-server says

Code:
[root@blackbox /usr/local/etc/rc.d]# ./mysql-server status
mysql is not running.

So tried to stop mysql_safe and start with mysql-server and now it says:

Code:
[root@blackbox /usr/local/etc/rc.d]# ./mysql-server start
Starting mysql.
[root@blackbox /usr/local/etc/rc.d]#

But it does not start. Error log states:

Code:
100309  9:24:52 [ERROR] /usr/local/libexec/mysqld: Can't create/write to file '/var/run/mysql.pid' (Errcode: 13)
100309  9:24:52 [ERROR] Can't start server: can't create PID file: Permission denied
100309 09:24:52 mysqld_safe mysqld from pid file /var/run/mysql.pid ended

I've tried (rather foolish...) recreating the .pid file in var/run with premissions and proper ownership to no avail.

So I'm guessing this should be set in /tmp?
Anyone know where this can be set? There are no relevant lines in my.conf
 
In my installation pid file (default) is located at --pid-file=/var/db/mysql/smadevnew.internal.net.pid which is owned by mysql.
 
Added a line to /usr/local/etc/my.cnf under [mysqld]

Code:
pid-file        = /var/db/mysql/mysql.pid

tried to restart from mysql_server and it still complains:

Code:
100309 10:22:51 [ERROR] /usr/local/libexec/mysqld: Can't create/write to file '/var/run/mysql.pid' (Errcode: 13)
100309 10:22:51 [ERROR] Can't start server: can't create PID file: Permission denied
100309 10:22:51 mysqld_safe mysqld from pid file /var/run/mysql.pid ended

When I did start with mysqld_safe it works flawlessly

Code:
100309 10:27:26 [Note] /usr/local/libexec/mysqld: ready for connections.
Version: '5.4.2-beta'  socket: '/tmp/mysql.sock'  port: 3306  FreeBSD port: mysql-server-5.4.2

So the question then remains, why mysql-server is blind to the mysql process? why can't it start the server?

Thanks for all the time so far btw! :)
 
Something is damaged/screwed in your mysql installation. my /usr/local/etc/rc.d/mysql-server explicitly contains:
Code:
....
mysql_user="mysql"
mysql_limits_args="-e -U ${mysql_user}"
pidfile="${mysql_dbdir}/`/bin/hostname`.pid"
command="/usr/local/bin/mysqld_safe"
....
so your pid should be like in /var/db/mysql/<your host name>.pid
+ most probably you dont need a my.cnf file, for your needs, so for the moment scrap it.

is your mysql-server up to date (mysql-server-5.0.90)?
Does your /usr/local/etc/rc.d/mysql-server look like:
Code:
root@smadevnew:~# ls -l /usr/local/etc/rc.d/mysql-server
-r-xr-xr-x  1 root  wheel  2110  9 Μαρ 10:34 /usr/local/etc/rc.d/mysql-server
root@smadevnew:~# md5 /usr/local/etc/rc.d/mysql-server
MD5 (/usr/local/etc/rc.d/mysql-server) = 529a104424903d2bc8e2750b8417a93f
??
 
Code:
[root@blackbox /usr/local/etc/rc.d]# pkg_info "mysql*"
Information for mysql-client-5.4.2:

Comment:
Multithreaded SQL database (client)

Required by:
mysql-server-5.4.2
php5-extensions-1.3
php5-mysql-5.2.11
php5-mysqli-5.2.11

Description:
MySQL is a very fast, multi-threaded, multi-user and robust SQL
(Structured Query Language) database server.

WWW: [url]http://www.mysql.com/[/url]

- Alex Dupre
[email]ale@FreeBSD.org[/email]

Information for mysql-server-5.4.2:

Comment:
Multithreaded SQL database (server)

Description:
MySQL is a very fast, multi-threaded, multi-user and robust SQL
(Structured Query Language) database server.

WWW: [url]http://www.mysql.com/[/url]

- Alex Dupre
[email]ale@FreeBSD.org[/email]


Code:
[root@blackbox /usr/local/etc/rc.d]# ll ./mysql-server
-r-xr-xr-x  1 root  wheel  1843 Mar  7 10:57 ./mysql-server
[root@blackbox /usr/local/etc/rc.d]# md5 ./mysql-server
MD5 (./mysql-server) = edc1eba38b2c92904f03bc90e7c69e29
renamed my.cnf. Tried to start with mysql-server and it hangs for 30 secs there and does nothing.
with mysqld_safe everything works as usual

does this mean I have a bad install?
should I begin to do backups to reinstall mysql from scratch??
 
from /usr/ports/MOVED
Code:
databases/mysql54-client|databases/mysql55-client|2010-01-04|Updated to milestone 2
databases/mysql54-server|databases/mysql55-server|2010-01-04|Updated to milestone 2
databases/mysql54-scripts|databases/mysql55-scripts|2010-01-04|Updated to milestone 2

now there is only /usr/ports/databases/mysql55-* ports, not 5.4.2
If i were you, i would deinstall it, install mysql-*-5.0.90, see if i can get it on a sane state, and then deinstall that and try with mysql55 (if 5.0.90 does not already suit your needs).

Before all that, please update your ports tree.
 
Will begin then with the backups :)

I will do what you suggest and come back to this thread to report

Thank you so much for your time
 
No my.cnf file is needed unless you really want to tweak mysql. Usually these 2 entries in /etc/rc.conf will suffice:

Code:
mysql_enable="YES"
mysql_dbdir="/storage/mysql/"

The pid file will be stored in $mysql_dbdir. Make sure the mysql user has read/write access to that directory. Your databases, logs, etc. will also get written to $mysql_dbdir.
 
And just for reference, this is what usually shows up in [cmd=]ps axww | grep sql[/cmd] for MySQL 5.1 and no .cnf whatsoever:

Code:
30786  ??  I      0:00.01 /bin/sh /usr/local/bin/mysqld_safe --defaults-extra-file=/var/db/mysql/my.cnf --user=mysql --datadir=/var/db/mysql 
--pid-file=/var/db/mysql/the.host.name.pid
30837  ??  I      0:57.20 /usr/local/libexec/mysqld --defaults-extra-file=/var/db/mysql/my.cnf --basedir=/usr/local --datadir=/var/db/mysql 
--user=mysql --log-error=/var/db/mysql/the.host.name.err --pid-file=/var/db/mysql/the.host.name.pid

Note that the /var/db/mysql/my.cnf file doesn't exist by default (and I don't have it).

For completeness' sake, I also dug up a MySQL 5.0 example:

Code:
47994  ??  I      0:00.01 /bin/sh /usr/local/bin/mysqld_safe --defaults-extra-file=/var/db/mysql/my.cnf --user=mysql --datadir=/var/db/mysql 
--socket=/tmp/mysql.sock --pid-file=/var/db/mysql/the.host.name.pid
48020  ??  I      0:35.68 /usr/local/libexec/mysqld --defaults-extra-file=/var/db/mysql/my.cnf --basedir=/usr/local --datadir=/var/db/mysql 
--user=mysql --pid-file=/var/db/mysql/the.host.name.pid --socket=/tmp/mysql.sock

The difference is that an explicit 'socket' shows up here.
 
works!

Well first off I would like to say thank you for all of you here in this thread for your outstanding help. This goes well beyond the "duties" you might have here and certainly way beyond all my expectations. (I had been told stories of the perils of posting to a *BSD forum...)

To the point:

Pkgs installed:

Code:
[root@blackbox /]# pkg_info "mysql*"
Information for mysql-client-5.5.1:
{...}
Required by:
apache-2.2.14_5
mysql-server-5.5.1
php5-5.2.12
php5-mysql-5.2.12
php5-readline-5.2.12
php5-xmlwriter-5.2.12
{...}
Information for mysql-server-5.5.1:
{...}

mysql-server script works as expected:

Code:
[root@blackbox /usr/local/etc/rc.d]# ./mysql-server status
mysql is running as pid 38994.
[root@blackbox /usr/local/etc/rc.d]# ./mysql-server stop
Stopping mysql.
Waiting for PIDS: 38994.
[root@blackbox /usr/local/etc/rc.d]# ./mysql-server start
Starting mysql.
[root@blackbox /usr/local/etc/rc.d]# ps waux | grep my
mysql    35806  6.4  2.1 188768 38036   4  S    11:29AM   0:00.39 /usr/local/libexec/mysqld --defaults-extra-file=/var/db/mysql/my.cnf 
--basedir=/usr/local --datadir=/var/db/mysql --user=mysql -
mysql    35754  0.0  0.1  3624  1564   4  S    11:29AM   0:00.02 /bin/sh /usr/local/bin/mysqld_safe --defaults-extra-file=/var/db/mysql/my.cnf 
--user=mysql --datadir=/var/db/mysql --pid-file=/v
root     35813  0.0  0.1  3492  1212   4  S+   11:29AM   0:00.00 grep my

Error log sees no major problem:

Code:
100310 11:29:37 [Note] /usr/local/libexec/mysqld: ready for connections.
Version: '5.5.1-m2'  socket: '/tmp/mysql.sock'  port: 3306  FreeBSD port: mysql-server-5.5.1

Everything works, no data has been lost, so I guess this is it.
Thank you all so much again for your exceptional help

PS Anyone coming to Edinburgh will find himself invited to a pint :)
 
aftr update mysql doesnt start on boot like usual

I have updated to 5.0.90 from ports and now mysql doesnt start at boot like usual !
If i /usr/local/etc/rc.d/mysql.server start it starts but Not on boot :<

Code:
 rc.conf
apache22_enable="YES"
mysql_enable="YES"
mysql_args="--user=mysql"

There is no error msg in the /var/db/mysql/errorlog.

On boot it just says "Starting Mysql" and hangs for like 20 seconds.
I suspect its in a loop from mysql.server script doing
Code:
mysql_poststart()
{
        count=0
        while [ $count -lt 10 ] ; do
                eval $mysqladmin $mysqladmin_args >/dev/null
                [ $? -eq 0 ] && return 0
                count=`expr $count + 1`
                sleep 1
        done
        return 1
}

I have reinstalled the port with no success. What am I missing ?


LATER EDIT probable cause of problems
: in /etc/my.cnf it it preferable to have

log-error = /absolute/path/to/error-log.err

this seems to have screwed it up for me.
(log-slow-queries has a relative path and works ok)
 
Back
Top