Recovering MySql Database after uninstalling WAMP? - mysql

I uninstalled WAMP on Win7. It removed everything but kept the data folder containing my database. After installing WAMP again on same directory, I thought it will recover MySQL database but it didn't.
It does show me my database and when I expand it in phpMyAdmin, I can see the tables but when I try to query them, it says, #1146 - Table 'tablename' doesn't exist
I searched and found a couple of posts. This post is close enough but it is for Linux and not exactly my case.
Any help will be appreciated.
UPDATE 1:
I tried repeating the steps mentioned here
Stopped MySQL service,
Renamed old database directory,
Started MySQL service,
Created new database with same name, and replaced all database files on it
Still got the same error.
UPDATE 2:
I tried repeating the steps mentioned here as well
Still getting the same error.
UPDATE 3:
Examining .err file revealed the below error:
[Warning] InnoDB: Cannot open table testdb/rules from the internal data dictionary of InnoDB though the .frm file for the table exists.
UPDATE 4:
CHECK TABLEtablename; resulted in following errors
Warning InnoDB: Tablespace is missing for table 'db/tablename'
Error Table 'db.tablename' doesn't exist
status Operation failed

Why don't you uninstall and then reinstall WAMP with backup datafiles in data directory. sometimes it solves problem.
I suggest you to always export your DB before doing any serious modifications.
Here is a thread for how to recover data This may be helpful to you

Related

xampp #1932 - Table 'phpmyadmin.pma__tracking' doesn't exist in engine

i tried to open my local Xampp to work on some projects, but when i go on Phpmyadmin and try to access to any database i retrieve the error message in the object.
I have to backup some db in every way because they are very important.
I tried to delete the pma_bookmark.frm and .ibd and then create again creates_table.sql but it doesn't solve my problem.
How can i solve this issue, but more, how can i save my databases and reload them on another installation or in another server ?

Can't delete tables in phpMyAdmin because they aren't visible in the structure

I've a local development environment with MAMP.
In this environment I'm using MySQL in version 5.6.35.
When I now want to import a database with phpMyAdmin, I get an internal server error everytime I try.
After some research I think there is a problem with the structure of the mysql database.
In the logs I found the following error:
InnoDB: Error: Table "mysql"."innodb_table_stats" not found.
And an hint to this page: https://dev.mysql.com/doc/refman/5.6/en/innodb-troubleshooting.html
There is also a link to a solution:
mysql error: Table "mysql"."innodb_table_stats" not found
My problem is, that I can't remove the tables (innodb_index_stats, innodb_table_stats, slave_master_info, slave_relay_log_info, slave_worker_info) from mysql.
They show up in the sidebar but not in the structure itself.
And if I click on them, I get more errors:
What I could do and already did is to remove the .frm & .ibd files of the tables above. But this had no effect.
Is there a way to repair or replace the mysql db?
I also tried the replair and update tools from MAMP. Without success.
I could solve the problem after I also deleted the .ibd files in the folder: /Library/Application Support/appsolute/MAMP PRO/db/mysql56

Restore InnoDB database

Today when trying to start mysql service, I got this error :
"mysql: job failed to start"
I needed to work with mysql, so I made a backup of my data directory (/var/lib/mysql) and reinstalled the server (mysql-server-5.6), note that I couldn't have used mysqldump because mysql wouldn't start, even with innodb_force_recovery>0
Now mysql starts just fine, but if I put back the old data directory, it shows the error mentioned before. I concluded that the problem comes from corrupted data
Now all I have is this data folder (containing ibdata1, ib_logfile* and such) and I want to restore all the data (not only the structure).
Thank you
"Old" and "new" are the same version 5.6? Try to check privilege of files, folders too.
Good luck.
I hope you tried all innodb_force_recovery values including 6. If MySQL still doesn't start follow instructions in my post https://twindb.com/recover-corrupt-mysql-database/ . There is a web interface to the data recovery toolkit on https://recovery.twindb.com/, you can upload and recover the database there if you are ok uploading the data.

MySQL corrupts after every server restart

I Have a bit of an odd problem. I am running MySQL and Drupal site from a windows environment (not by choice but it is just how things have worked out) and most of the time the site is fine however every time the server is restarted (from updates or for maintenance) The MySQL Database will corrupt.
When I log in to MySQL Work bench I notice that the server status is stopped and when I try to start it I get the error:
ERROR Fatal error: Can't open and lock privilege tables: Can't find file: 'user' (errno: 2 - No such file or directory)
and then MySQL Server fails to restart.
The only way around this problem is to delete data folder in the ProgramData/MySQL and then replace it with a backup from a fresh install of MySQL then import a backup of my tables and recreate my users.
My Question is what is causing MySQL to corrupt at every sever restart and what can I do to prevent this happening moving forward?
This occurs when mysql can not find or do not have permissions to user.MYD or user.MYI or user.frm in the data directory. When you start mysql, make sure that these files exist in data directory. You can just copy those files when mysql does not start
This worked for me:
Stick with the 32 bit.
Uninstall and make sure you then DELETE the mysql-data folder and all its subfolders before installing, and prefer to use the 32 bit (sometimes 64 bit versions are the problem).
(Source)

Mysql gives me:"Can't open and lock privilege tables: Table 'host' is read only"

I am facing problem restoring the mysql database. My primary database was mysql5.1 and now I am trying to copy it to mysql5.5. The database was backed by using Xtrabackup.
I am using Ubuntu 12.04.3 LTS on this server, mysql version is : 5.5.32-0ubuntu0.12.04.1-log
I have followed all the steps to restore using Xtrabackup, this created database files, which I have copied to a tmp directory.
I have modified my.cnf to point to this tmp directory. I have changed the tmp directory permissions and changed the ownership of the files to mysql user.
drwxr-xr-x 12 mysql mysql 4096 Sep 10 10:04 base
Now when I start the mysql server I get this error "[ERROR] Fatal error: Can't open and lock privilege tables: Table 'host' is read only"
I have given a try as follows:
Even tried installing mysql5.1 to see if that was the issue.
tried 'chcon mysql_db_t' to change the context but it gives me "can't apply partial context to unlabelled file"
I have used --skip-grant to get into database, but using this I can only access innodb tables only, MyIsam tables throw read-only error
After --skip-grant, I have used upgrade_mysql this throws me error that many tables are read-only.
I have removed apparmor too. and restarted too.
I have restored a different database(5.1 to 5.5) previously on Ubuntu 12.04.2 LTS without any issues.
Can some please point me in right direction, I am not sure whats wrong with permissions.
Thanks in advance.
Answering my own question,
The issue is with AppArmor. I am not sure why MySql is unable to access files even after uninstalling AppArmor.
Reinstalled AppArmor and moved the MySql profile under disabled profiles of AppArmor, even then it did not work.
I copied the database files under /var/lib/mysql/ and MySql stopped throwing errors