# MySQL errors after power outage



## SQUIGMUIRE (Jun 29, 2015)

I could really use some help. I had a power outage last Monday and ever since I have ran scans to get FreeBSD back up. It will work for a little but none of the database are working then at least once a day it locks up. I have to reboot it and do another scan usually on g and sometimes h. Any help is really appreciated.


----------



## SQUIGMUIRE (Jun 30, 2015)

I think I might have a little more information...I was poking around and it shows that mysql is not running and when I try to start mysql it will not start...Any Suggestions?


----------



## wblock@ (Jun 30, 2015)

The first thing to do is check your backups.

The second thing to do--after verifying that you have full backups--is to boot in single user mode and use fsck(8) the filesystems.

If there are still problems after that, please post the exact output it shows when you try to start MySQL.


----------



## SQUIGMUIRE (Jun 30, 2015)

how would I check for a backup?


----------



## SirDice (Jun 30, 2015)

SQUIGMUIRE said:


> how would I check for a backup?


This more or less implies you don't have any.


----------



## SQUIGMUIRE (Jun 30, 2015)

I might I am just learning on the fly someone else setup the server.  And I havent touch bsd in like 12 years so what I did know I barely remember.  Any help would be appreciated.


----------



## usdmatt (Jun 30, 2015)

Have a look in /var/db/mysql/_hostname_.err to see if MySQL is logging any errors when it starts.
It may well be that one or more databases/tables are corrupt. If so, you'll have to follow the MySQL documentation to attempt recovery. If it's not corruption, hopefully the error log will say what's wrong.

If the machine is locking up regularly, that's not a particularly good sign. It is wise me asking how old the machine is or the version of FreeBSD on it..?

If it was me and I was unsure about backups, I think I'd be looking to get as much data backed up as possible while it was running before worrying about fixing the stability problems.


----------



## SQUIGMUIRE (Jun 30, 2015)

I do know its old the last admin told me it needed to be upgraded but said that moving the databases to a new version would be a big headache.  Thats why I was trying to at least get it back up first then work on the rest.


----------



## SQUIGMUIRE (Jul 2, 2015)

Ok I tried using `tail /var/db/mysql/[I]hostname[/I].err` on my server and said file does not exist is there something I'm doing wrong?  Thank you for your help.


----------



## SirDice (Jul 2, 2015)

Replace _hostname_ with the actual hostname of the machine.


----------



## SQUIGMUIRE (Jul 2, 2015)

I tried that and still get the same error...is there a command to view everything in a directory page by page...I do ls and it scrolls to fast before I can see the top part of the list in mysql directory


----------



## usdmatt (Jul 2, 2015)

You could run one of the following to either page the list, or only show files ending in err.
It's possible MySQL may be using a different location although /var/db/mysql is the default.


```
# ls |more
# ls *err
```


----------



## SirDice (Jul 2, 2015)

I suggest learning to use less(1) and/or more(1).


----------



## SQUIGMUIRE (Jul 2, 2015)

Awesome that helped now I was able to find it.  The error log is showing that there are tables that are marked as crashed and should be repaired could you help me with the command to do that


----------



## SirDice (Jul 2, 2015)

Login MySQL and use "REPAIR TABLE <tablename>;".

https://dev.mysql.com/doc/refman/5.5/en/repair-table.html


----------



## SQUIGMUIRE (Jul 2, 2015)

How do I login to MYSQL


----------



## SQUIGMUIRE (Jul 2, 2015)

Is there a command to repair all tables or do I need to do each one individually


----------



## SQUIGMUIRE (Jul 2, 2015)

Ok I figured out how to get into mysql but couldn't get the repair table to work can you tell me the exact command also I found `mysqlcheck` command in my research but when I run it after about 30 if that it comes up with a error 2013 lost connection to MYSQL server during query any suggestions on how to correct that?


----------



## tingo (Jul 2, 2015)

Learn how to use apropos(1). If you run `$ apropos mysql` it will tell you about all related man pages on the system.


----------



## SQUIGMUIRE (Jul 2, 2015)

How will this help me with the timeout issue?  If I'm reading correctly this is just a search utility?


----------



## tingo (Jul 4, 2015)

It will tell you about mysqlrepair.


----------

