# MYSQL problem on Gentoo server restart

## scumsurfer

Hi,

I have  a problem on 4 of my Gentoo servers where MYSQL doesnt want to start after a system reboot. When the server starts up after a reboot I get the following errors:

* Starting mysql ...

 * "/var/run/mysqld/mysqld.pid" is still present and the process is running.

 * Please stop it "kill 4856" maybe ?

This causes all the services which depend on mysql to also not start. I then need to issue the command /etc/init.d/mysql restart untill it starts ok, which can sometimes be a few times,  getting the same error above. When I try to kill the mentioned process, I get a message saying that it cant find the process. I have looked in the logs and cant find anything showing to a specific problem. 

Once MYSQL has started ok, I can restart MYSQL with no problems. 

I have some Ubuntu based servers as well and dont get this happening there, so thinking that the problem might be Gentoo related? The servers that are giving the problem all run different services. Any ideas please?

Thanks

Carl

----------

## nurachi

What's the output when you stop MySQL ?

```
/etc/init.d/mysql stop
```

Do you have something in your /var/log/mysql/mysqld.err (or the relevant file according to your config).

If your systems are keeping /var/run/mysqld/mysqld.pid instead of deleting it, there might be some logs in syslog of such a failure. No?

----------

## Exil

mysql stop will not do that. 

/etc/init.d/mysql zap will clean mysql status to not runing.

----------

## scumsurfer

Hi,

When I issue the command "/etc/init.d/mysql stop" mysql stops ok and can be started again without any error. My problem only seems to happen when I restart the server.

My /var/log/mysql/mysqld.err contains the following lines corresponding to a system reboot

081106 10:18:00 [Note] /usr/sbin/mysqld: Normal shutdown

081106 10:18:00  InnoDB: Starting shutdown...

081106 10:18:01  InnoDB: Shutdown completed; log sequence number 0 43655

081106 10:18:01 [Note] /usr/sbin/mysqld: Shutdown complete

081106 10:07:26  InnoDB: Started; log sequence number 0 43655

081106 10:07:31 [Note] /usr/sbin/mysqld: ready for connections.

Version: '5.0.60-log'  socket: '/var/run/mysqld/mysqld.sock'  port: 3306  Gentoo Linux mysql-5.0.60-r1

According to this log the mysql service started ok, but the services which depend on mysql did not start as mysql apparently did not start ok. Please see below:

mail ~ # /etc/init.d/MailScanner status

 * status:  stopped

mail ~ # /etc/init.d/MailScanner start

 * Starting mysql ...

 * "/var/run/mysqld/mysqld.pid" is still present and the process is running.

 * Please stop it "kill 4834" maybe ?                                                                                   [ !! ]

 * ERROR:  cannot start MailScanner as mysql could not start

mail ~ # /etc/init.d/mysql start

 * Starting mysql ...

 * Starting mysql (/etc/mysql/my.cnf)                                                                                   [ ok ]

mail ~ # /etc/init.d/MailScanner start

 * Starting MailScanner ...

Starting MailScanner... Done.                                                                                           [ ok ]

mail ~ #   

There is no logs indicating any problem with the mysql pid.

----------

## nurachi

Two suggestions:

- be sure to have Mailscanner started at the same runlevel (or before) than Mysql (rc-update add Mailscanner default).

- try to remove PARALLEL_FETCH from /etc.conf.d/rc or /etc/rc.conf if you have set it. System sartup'll be slower but safer.

----------

## scumsurfer

Hi,

Parallel startup is disabled in /etc/conf.f/rc and MailScanner is already in the same startup level even though it is dependant on MySql

Any other ideas please?

Thanks for the help....

Carl

----------

## fbcyborg

Hello, 

I have this problem too! My dev-db/mysql version is 5.0.60-r1. Sometimes during the boot process, mysql doesn't start.

If I try to start it manually once I've logged in I get:

```
# /etc/init.d/mysql start

 * Starting mysql ...

 * "/var/run/mysqld/mysqld.pid" is still present and the process is running.

 * Please stop it "kill 7134" maybe ?   
```

It seems there's some process creating the mysqld.pid at the boot time before the mysqld init script is called by the runlevel. Maybe that's the reason why it doesn't start.

This occurs to me on two PCs, but it's doesn't happen on every boot process. Strange! Isn't it?

I don't have the parallel fetch activated.

I guess mysql has a bug!!! This didn't happen before!

Here's what appens at the boot time:

```
* Starting mysql ...                                                                       

* Starting mysql (/etc/mysql/my.cnf)                                                       

* MySQL not started (0)                                                                     [ !! ]

* Starting sshd ...                                                                         [ ok ]
```

One of the bad things, is that sometime sshd doesn't start and the boot process is interrupted at the last but one line I've just quoted above. Obviously, other following services don't start too.

In addiction, I had other problems in the past, to load mysql at boot, and I thought to solve it uncommenting the following line in the my.cnf file:

```
skip-innodb
```

But it seems to not be the definitive solution because the problem occurs again!

EDIT: Another strange thing happens if I wait about ten minutes, once mysql failed to start at boot time:

```
# /etc/init.d/mysql start

 * Starting mysql ...

 * Starting mysql (/etc/mysql/my.cnf) 
```

 :Question:   :Question:   :Question:   :Rolling Eyes:   :Rolling Eyes:   :Rolling Eyes: 

I didn't do anything!!! Why, it's able to start now??

----------

## oc666

There is a bug on this in bugzilla:

https://bugs.gentoo.org/254133

----------

