Take the 2-minute tour ×
Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. It's 100% free, no registration required.

I am having a problem with my database it does not want to start :(

the server is running on linux centos 6.2

it was working until I emptied the logs I don't know if this have anything to do with my problem !

the log says the following :

131212 15:52:05 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql
131212 15:52:06  InnoDB: Initializing buffer pool, size = 8.0M
131212 15:52:06  InnoDB: Completed initialization of buffer pool
InnoDB: The log sequence number in ibdata files does not match
InnoDB: the log sequence number in the ib_logfiles!
131212 15:52:06  InnoDB: Database was not shut down normally!
InnoDB: Starting crash recovery.
InnoDB: Reading tablespace information from the .ibd files...
InnoDB: Restoring possible half-written data pages from the doublewrite
InnoDB: buffer...
131212 15:52:06  InnoDB: Started; log sequence number 2 2565027428
131212 15:52:06 [ERROR] Fatal error: Can't open and lock privilege tables: Can't find     file: 'db' (errno: 2)
131212 15:52:06 mysqld_safe mysqld from pid file /var/run/mysqld/mysqld.pid ended

Edit

here is my "my.cnf" :

[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock

user=mysql
max_connections=1500
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0

[mysqld_safe]
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid

also this is the output of ls -l /var/lib/mysql/ :

-rwxr-xr-x 1 mysql mysql 1512046592 Dec 12 17:02 ibdata1
-rwxr-xr-x 1 mysql mysql    5242880 Dec 12 17:19 ib_logfile0
-rwxr-xr-x 1 mysql mysql    5242880 Dec 11 09:54 ib_logfile1
drwxr-xr-x 2 mysql mysql       4096 Dec 12 09:02 mysql
drwxr-xr-x 2 mysql mysql      12288 Dec 12 17:15 nagios
drwxr-xr-x 2 mysql mysql      20480 Dec  9 09:05 nagiosql
drwxr-xr-x 2 mysql mysql       4096 Oct 27 10:45 test

any suggestions?

share|improve this question
    
The ur-problem seems to be that: "Can't find file: 'db'". It seems your InnoDB is damaged. You need recovery. –  Peter Horvath Dec 12 '13 at 16:49
    
ok thanks but how can I do this recovery? –  X-Ware Dec 12 '13 at 17:01
    
What is your datadir ? Goto that folder in Linux, and run ls -l and post that output. Also, please post your /etc/my.cnf in the question as well. –  RolandoMySQLDBA Dec 12 '13 at 17:20
    
You mentioned you emptied the logs. What exactly did you empty? Did you delete the ib_logfile0 and ib_logfile1 files? –  RolandoMySQLDBA Dec 12 '13 at 17:33
    
@RolandoMySQLDBA I put them in the question :) –  X-Ware Dec 12 '13 at 17:34
show 7 more comments

1 Answer 1

up vote 0 down vote accepted

I was able to solve this problem by doing the following :

  1. Move all the contents of my data directory (in my case /var/lib/mysql/ ) to a safe place.
  2. Execute the command service mysqld start, this will:
    • recreate two DBs:
      • mysql
      • test
    • recreate ibdata1, ib_logfile0, and ib_logfile0
  3. Copy the contents that you backed up (in step 1) from the safe place to the data directory again, of course, except both mysql and test directories.
  4. Using the following command mysqladmin -u root -p'' password yournewpass reset the password of your root user.

An Advice:

Always make sure you make a backup of your databases structure and data to avoid looping in such loops, just delete every thing, re-install your engine, and restore your data :)

share|improve this answer
    
Your luck was your tables are MyISAM :) –  Maxime FOUILLEUL Dec 16 '13 at 9:51
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.