# [SOLVED] MYSQL won't restart after a power failure

## mlnzigzag

Hi ppl,

i got a very strange issue with my mysql installation, started after the server had a power loss and an unclean shutdown

the root filesystem has already been checked with e2fsck that found and corrected a lot of errors, but the server still doesn't start.

following is the output of the shell

i even tried starting the server with a newly initialized database, but nothing changes

i tried to reemerge (recompiling) as well as reinstalling the package with --usepkgonly but the following is still printed out to the shell

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

dbg:  >>> start()

 * Starting mysql ...

dbg:  >>> get_slot_config()

dbg:  srv                0

dbg:  srv_slot           0

dbg:  srv_num            

dbg:  tmp_eval           mysql_slot_0[@]

dbg:  conf_d_parameters  

dbg:  MY_SUFFIX          

dbg:  chroot dir => 

dbg:  niceness   => 

dbg:  basedir    => /usr

dbg:  datadir    => /var/lib/mysql

dbg:  pidfile    => /var/run/mysqld/mysqld.pid

dbg:  socket     => /var/run/mysqld/mysqld.sock

dbg:  Unamanged  =>  

dbg:  <<< get_slot_config() ok

dbg:  >>> checkconfig("/var/lib/mysql")

dbg:  <<< checkconfig() ok

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

dbg:  starting mysqld with: --defaults-file=/etc/mysql/my.cnf   --basedir=/usr --datadir=/var/lib/mysql --pid-file=/var/run/mysqld/mysqld.pid --socket=/var/run/mysqld/mysqld.sock

Starting /usr/sbin/mysqld...

Detaching to start /usr/sbin/mysqld...done.

dbg:  

dbg:  

 * MySQL NOT started (1)

dbg:  <<< start() 
```

these are the mysqld.err lines relative to this attempt to start the server:

```
090727 12:21:04 [Warning] No argument was provided to --log-bin, and --log-bin-index was not used; so replication may break when this MySQL server acts as a master and has his hostname changed!! Please use '--log-bin=mysqld-bin' to avoid this problem.

090727 12:21:04 [ERROR] Can't start server : Bind on unix socket: Permission denied

090727 12:21:04 [ERROR] Do you already have another mysqld server running on socket: /var/run/mysqld/mysqld.sock ?

090727 12:21:04 [ERROR] Aborting

090727 12:21:04 [Note] /usr/sbin/mysqld: Shutdown complete

```

no need to say that i DON'T have another mysqld server running on this socket (wich doesn't exists)

Please feel free to ask for any further informations i may be lacking!

Thanks a lot in advance for your patience and help

MarcoLast edited by mlnzigzag on Mon Jul 27, 2009 1:23 pm; edited 1 time in total

----------

## cach0rr0

Try this:

```

chown -R mysql:mysql /var/run/mysqld

```

then try starting up mysql.

----------

## mlnzigzag

tnx a lot mate, we did it!

i just did as you said and it instantly came up

just wonderin why the unclean shutdown created this issue...

but it's much less important than having the service back running

thank you very much

Marco

----------

## cach0rr0

permissions issue 

the .sock file likely had a different owner (presumably root) 

so mysql was unable to remove it and recreate it when attempting to do so as the 'mysql' user. This is something it will do on every startup. 

If the .sock is owned by mysql, it isnt a problem, because mysql has permissions to nuke the .sock and recreate it - and it will do this happily upon starting up, as it assumes the presence of an orphaned .sock means an unclean shutdown that should prompt it to nuke the .sock and recreate. 

Of course when nit can't nuke and recreate, it bombs out.

a blind guess - perhaps there was a setuid operation in progress that never completed? dunno, again jsut a blind guess

----------

## mlnzigzag

I'm not so sure the problem is totally fixed.

i found the webserver returning the following error in mysql-php-related pages

```

Warning: preg_match() [function.preg-match]: Internal pcre_fullinfo() error -3 in /var/www/localhost/htdocs/medicomd/mainfile.php on line 39

Warning: Cannot modify header information - headers already sent by (output started at /var/www/localhost/htdocs/medicomd/mainfile.php:39) in /var/www/localhost/htdocs/medicomd/mainfile.php on line 178

non connesso
```

Please check it out and tell me  if you have some hints!

Marco

----------

## cach0rr0

you might see if you can connect to the DB from the command line, do a few basic queries, etc

if it's genuinely hosed, mysqlcheck/myisamchk will be your friend

----------

## mlnzigzag

standard queries returned some errors, so i've run:

```

mysqlcheck -uroot -p --all-databases

```

and it returned many errors, most of the tables had to be repaired

then i've run

```

mysqlcheck -uroot -p --auto-repair --all-databases

```

and *ALL* the tables with errors have been repaired, the box printed out a list of

NAME_OF_TABLE1 ......OK

NAME_OF_TABLE2 ......OK

ETC..

Anyway, right now, if i connect to the mysql instance using Mysql Administrator i can't see all the tables in the catalog;

i just see the ones (actually three) that had no errors in it.

Could you please tell me how to let the server re-read all the tables?

I even tried to restart the service, but it didn't make it.

Thanks a lot for your replies

Marco

----------

