Solved

MYSQL ERROR 2002 (HY000) - Can't Start

Posted on 2011-09-05
4
1,618 Views
Last Modified: 2012-05-12
Hi,

I have a crash on my Linux Ubuntu 9 with Mysql. I have this error :

ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (111)


And in my log fil :

Var/log/mysql/error.log



InnoDB: Starting crash recovery.
InnoDB: Reading tablespace information from the .ibd files...
InnoDB: Restoring possible half-written data pages from the doublewrite
InnoDB: buffer...
InnoDB: Doing recovery: scanned up to log sequence number 22 2307965626
110905 12:14:48  InnoDB: Starting an apply batch of log records to the database...
InnoDB: Progress in percents: 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99
InnoDB: Apply batch completed
110905 12:14:49  InnoDB: Started; log sequence number 22 2307965626
110905 12:14:49 [Note] Event Scheduler: Loaded 0 events
110905 12:14:49 [Note] /usr/sbin/mysqld: ready for connections.
Version: '5.1.41-3ubuntu12.10'  socket: '/var/run/mysqld/mysqld.sock'  port: 3306  (Ubuntu)
110905 12:14:50 /usr/sbin/mysqld: Table './wp_cefrio_blogue/global_zd_stats_entry' is marked as crashed and last (automatic?) repair failed
110905 12:14:50 /usr/sbin/mysqld: Table './wp_cefrio_blogue/global_zd_stats_entry' is marked as crashed and last (automatic?) repair failed


Anyone can help me,

thank's

Jean-Sebastien
0
Comment
Question by:jeansebgrenon
  • 3
4 Comments
 

Author Comment

by:jeansebgrenon
ID: 36485484
I put this option in my my.cnf file :

innodb_force_recovery = 2

And I can open myswl, but I have this message in log file :


InnoDB: A new raw disk partition was initialized or
InnoDB: innodb_force_recovery is on: we do not allow
InnoDB: database modifications by the user. Shut down
InnoDB: mysqld and edit my.cnf so that newraw is replaced
InnoDB: with raw, and innodb_force_... is removed.
InnoDB: A new raw disk partition was initialized or
InnoDB: innodb_force_recovery is on: we do not allow
InnoDB: database modifications by the user. Shut down
InnoDB: mysqld and edit my.cnf so that newraw is replaced
InnoDB: with raw, and innodb_force_... is removed.



Any suggestion?

Thank's

Jean-Sebastien
0
 
LVL 13

Accepted Solution

by:
LinuxGuru earned 500 total points
ID: 36486422
First of all try to shutdown the mysql server and then start it. If it still shows the error I would recommend you to dump the table or the database that caused the problem, delete, recreate it, and import the data back in.
0
 

Assisted Solution

by:jeansebgrenon
jeansebgrenon earned 0 total points
ID: 36488157
Hi testez, I tried your suggestion, but with some add.

This is what I do to restore my MYSQL Server :



First step was turning-on InnoDB force-recovery mode, where InnoDB starts but ignores all UPDATEs and INSERTs.
 
Add this line to /etc/my.cnf:
 

innodb_force_recovery = 2



Now we can restart the database:
 

/usr/local/bin/mysqld_safe

(Note: If MySQL doesn't restart, keep increasing the innodb_force_recovery number until you get to innodb_force_recovery = 8)
 
Save all data into a temporary alldb.sql (this next command can take a while to finish):
 

mysqldump --force --compress --triggers --routines --create-options -uUSERNAME -pPASSWORD --all-databases > /usr/alldb.sql

Shutdown the database again:
 

mysqladmin -uUSERNAME -pPASSWORD shutdown

Delete the database directory. (Note: In my case the data was under /usr/local/var. Your setup may be different. Make sure you're deleting the correct directory)
 

rm -fdr /usr/local/var

Recreate the database directory and install MySQL basic tables
 

mkdir /usr/local/var
chown -R mysql:mysql /usr/local/var
/usr/local/bin/mysql_install_db
chown -R mysql:mysql /usr/local/var

Remove innodb_force_recovery from /etc/my.cnf and restart database:
 

/usr/local/bin/mysqld_safe

Import all the data back (this next command can take a while to finish):
 

mysql -uroot --compress < /usr/alldb.sql

And finally - flush MySQL privileges (because we're also updating the MySQL table)
 

/usr/local/bin/mysqladmin -uroot flush-privileges

Credit to this solution, Mike Peters : http://www.softwareprojects.com/resources/programming/t-how-to-fix-mysql-database-myisam-innodb-1634.html
0
 

Author Closing Comment

by:jeansebgrenon
ID: 36518344
I my comment I have put the command to dump all DB, like me using innoDB crasching.

And some other few command to help.
0

Featured Post

Migrating Your Company's PCs

To keep pace with competitors, businesses must keep employees productive, and that means providing them with the latest technology. This document provides the tips and tricks you need to help you migrate an outdated PC fleet to new desktops, laptops, and tablets.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Foreword This is an old article.  Instead of using the MySQL extension that was used in the original code examples, please choose one of the currently supported database extensions instead.  More information is available here: MySQLi / PDO (http://…
If you've heard about htaccess and it sounds like it does what you want, but you're not sure how it works... well, you're in the right place. Read on. Some Basics #1. It's a file and its filename is .htaccess (yes, with a dot in the front). #…
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

785 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question