| Linux - Server This forum is for the discussion of Linux Software used in a server related context. |
| Notices |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
 |
GNU/Linux Basic Guide
This 255-page guide will provide you with the keys to understand the philosophy of free software, teach you how to use and handle it, and give you the tools required to move easily in the world of GNU/Linux. Many users and administrators will be taking their first steps with this GNU/Linux Basic guide and it will show you how to approach and solve the problems you encounter.
Click Here to receive this Complete Guide absolutely free. |
|
 |
07-27-2012, 11:46 AM
|
#1
|
|
Member
Registered: Jun 2009
Distribution: Slackware
Posts: 103
Rep:
|
MySQL tables gone
Hi!
I'm not sure if this is the right subforum, but here it is.
After automatic update of mysql, I lost all tables in a database. I can't see them from console or phpMyAdmin. But when I go to /var/lib/mysql there it is 300MB directory. What happend and how can I get this database back?
I tried repairing with mysqlcheck, but nothing happened.
|
|
|
|
07-27-2012, 11:48 AM
|
#2
|
|
Senior Member
Registered: Mar 2012
Distribution: Red Hat
Posts: 1,380
|
After upgrading MySQL you should ALWAYS do the following commands:
Code:
mysql_upgrade -uroot -p
mysqlcheck -Aro -uroot -p
That should update your mysql database so that it can read the other databases correctly
|
|
|
|
07-27-2012, 12:13 PM
|
#3
|
|
Member
Registered: Jun 2009
Distribution: Slackware
Posts: 103
Original Poster
Rep:
|
Hi Kustom42 and thanks for your response!
Automatic update is performed by cPanel and I guess it executes that command after updates. Nevertheless, I just tried with those and still nothing. No tables. Perhaps it wasn't due to update, but I have no idea why this happened.
Any other suggestion?
|
|
|
|
07-27-2012, 12:17 PM
|
#4
|
|
Senior Member
Registered: Mar 2012
Distribution: Red Hat
Posts: 1,380
|
What is the output of
Code:
ls -al /var/lib/mysql/
mysql -uroot -p -Dmysql -e"SELECT * FROM information_schema.tables WHERE table_schema = 'YourDatabaseName';"
|
|
|
|
07-27-2012, 12:26 PM
|
#5
|
|
Member
Registered: Jun 2009
Distribution: Slackware
Posts: 103
Original Poster
Rep:
|
Code:
ls -al /var/lib/mysql/
total 30800
drwxr-x--x 26 mysql mysql 4096 Jul 27 11:53 ./
drwxr-xr-x 75 root root 4096 Jul 3 05:19 ../
drwx------ 2 mysql mysql 4096 Jul 27 11:54 cphulkd/
drwx------ 2 mysql mysql 4096 Jul 27 11:54 eximstats/
drwx------ 2 mysql mysql 4096 Jul 27 11:54 horde/
-rw-rw---- 1 mysql mysql 18874368 Jul 27 10:57 ibdata1
-rw-rw---- 1 mysql mysql 5242880 Jul 27 10:57 ib_logfile0
-rw-rw---- 1 mysql mysql 0 Jul 27 10:57 ib_logfile1
drwx------ 2 mysql mysql 12288 Jul 27 11:55 company_workpress/
drwx------ 2 mysql mysql 12288 Jul 27 11:05 company_products/
drwx--x--x 2 mysql mysql 4096 Jul 27 11:55 mysql/
srwxrwxrwx 1 mysql mysql 0 Jul 27 11:08 mysql.sock=
-rw-r--r-- 1 root root 6 Jul 27 11:05 mysql_upgrade_info
drwx------ 2 mysql mysql 4096 Jul 3 05:19 roundcube/
company_products is problematic database.
Second command gives nothing. Empty set.
|
|
|
|
07-27-2012, 12:37 PM
|
#6
|
|
Senior Member
Registered: Mar 2012
Distribution: Red Hat
Posts: 1,380
|
Quote:
Originally Posted by diwljina
company_products is problematic database.
Second command gives nothing. Empty set.
|
Did you replace the 'YourDatabaseName' with company_products?
What does
Code:
mysql -uroot -p -Dmysql -e"SELECT * FROM information_schema.tables;"
give you?
|
|
|
|
07-27-2012, 01:01 PM
|
#7
|
|
Member
Registered: Jun 2009
Distribution: Slackware
Posts: 103
Original Poster
Rep:
|
I did replaced it. And that command gives me information about other working tables. It's just problematic database that gives me empty set.
|
|
|
|
07-27-2012, 04:37 PM
|
#8
|
|
Member
Registered: Jun 2009
Distribution: Slackware
Posts: 103
Original Poster
Rep:
|
Since all .frm files were gone, I managed to find some old backup. I restored old backup and that way restored tables definition. Then I copied new .MYD and .MYI over this restored, while retaining .frm's. Last step was repairing database with mysqlcheck -r and everything was working like before.
Kustom42, thanks for your help, anyway. 
|
|
|
|
07-27-2012, 04:41 PM
|
#9
|
|
Senior Member
Registered: Mar 2012
Distribution: Red Hat
Posts: 1,380
|
Yep, that was the next step. Restoring the actual .MYI and .MYD files is sketchy but it can work. The fact that you were getting no info when doing the query against your info schema table confirms that the issue is with your .frm files which tell the MySQL database your table info. Just wanted to add this follow up for anyone else that runs into the issue. This is the last step you can attempt before you are up the creek so to speak.
|
|
|
|
07-27-2012, 05:03 PM
|
#10
|
|
Member
Registered: Jun 2009
Distribution: Slackware
Posts: 103
Original Poster
Rep:
|
So, without frms it would be impossible to restore database?
|
|
|
|
07-30-2012, 11:36 AM
|
#11
|
|
Senior Member
Registered: Mar 2012
Distribution: Red Hat
Posts: 1,380
|
Without any one of the files(.frm, .MYI, .MYD) it would be impossible to restore. It is good practice to setup a cron job to make a mysqldump of your databases for backup purposes.
|
|
|
|
07-30-2012, 11:39 AM
|
#12
|
|
Member
Registered: Aug 2011
Location: Dublin
Distribution: Centos 5
Posts: 538
Rep: 
|
Quote:
Originally Posted by Kustom42
Without any one of the files(.frm, .MYI, .MYD) it would be impossible to restore. It is good practice to setup a cron job to make a mysqldump of your databases for backup purposes.
|
It's even better practise to replicate them to a slave server and take backups from the slave 
|
|
|
|
| Thread Tools |
Search this Thread |
|
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT -5. The time now is 03:04 PM.
|
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|