MySQL Phantom tables - mysql

I did a drop query on a MySQL table... my GUI interface crashed right in the middle of the process. The table does not exist in the listing; however, when I go to make a new one it says that there is already a table with that name. I tried doing a DROP TABLE and a RENAME on this phantom table but both queries run endlessly.
FYI I am unable to restart MySQL because shit might break on our live sites.
Any help is greatly appreciated.

Try repairing the table :
http://dev.mysql.com/doc/refman/5.1/en/repair-table.html

The tablename matches three files in the filesystem with a .frm, .myd and .myi extension (for the table definition, data and index files respectively) One of these files is corrupted, which prevents MySQL from carrying out your order.
Option 1 delete files from the filesystem
Have a look at the filesystem to see which file still exists.
If the .frm file is missing, you should be able to delete the other two files.
If the .frm file is still there do not delete, MySQL still has a lock on that file.
Option 2 repair the database
Use the myisamchk to diagnose and repair your database.
See: http://forge.mysql.com/wiki/MySQL_Internals_File_Formats
And: http://dev.mysql.com/doc/refman/5.0/en/myisam-repair.html

Check the directory where mysql stores the databases. On Ubuntu it's in /var/lib/mysql, but it may be different depending on your OS and configuration. Inside that directory there is a directory for every database, go into the directory for the problematic database, and delete any file that are the table name with extensions .frm, .myd, and .myi.

Sounds like you have a disconnect between what you have and what your server thinks you have.
You'll need SSH access and have to repair the table manually.
Log in to SSH and type:
mysql -u root -p
And enter your root mysql password.
Then
show databases
And it will list all the databases on your server.
Select the database you want with
use databasename;
Then
show tables;
This should list every table in your database. It's likely that it's still shows up there, so do a
drop tablename;
Hopefully that will correct your issue.

Ended up restoring from a backup... editing files in the file system is scary and may have required a restart.

Related

Some file lost in MySQL database. How to re-create it in proper way?

The problem is, that one MYI and one MYD file from MySQL database has been accidentally deleted. The only file left intact is FRM one. Only one table from the whole database is damaged that way, all other tables are OK and the database works generally fine, except the table with deleted files, which is obviously inaccessible.
There's a full database dump in pure SQL format available.
The question is, how do I re-create these files and table in safe and proper manner?
My first idea was to extract the full create table command from the dump and run it on live database. It's not so easy, as the whole dump file has over 10GB, so any operations within its content are really pain in . Yes, I know about sed and know how to use it - but I consider it the last option to choose.
Second and current idea is to create copy of this database on independent server, make a dump of the table in question and then use resulting SQL file to create the table again on the production server. I'm not quite experienced with MySQL administration tasks (well, just basic ones), but for me this option seems to be safe and reasonable.
Will the second option work as I expect?
Is it the best option, or are there any more recommendable solutions?
Thank you in advance for your help.
The simplest solution is to copy the table you deleted. There's a chance mysqld still has an open file handle to the data files you deleted. On UNIX/Linux/OS X, a file isn't truly deleted while some process still has an open file handle to it.
So you might be able to do this:
mysql> CREATE TABLE mytable_copy LIKE mytable;
mysql> INSERT INTO mytable_copy SELECT * FROM mytable;
If you've restarted MySQL Server since you deleted the files, this won't work. If the server has closed its file handle to the data file, this won't work. If you're on Windows, I have no idea.
The next simplest solution is to restore your existing 10GB dump file to a temporary instance of MySQL Server, as you said. I'd use MySQL Sandbox but some people would use a virtual machine, or if you're using an AWS environment, launch a spot EC2 instance or a small RDS instance.
Then dump just the table you need:
mysqldump -h tempserver mydatabase mytable > mytable.sql
Then restore it to your real server.
mysql -h realserver mydatabase < mytable.sql
(I'm omitting the user & password options, I prefer to put those in .my.cnf anyway)

strange results when manually database copy to another server [duplicate]

I changed the datadir of a MySQL installation and all the bases moved correctly except for one.
I can connect and USE the database. SHOW TABLES also returns me all the tables correctly, and the files of each table exists on the MySQL data directory.
However, when I try to SELECT something from the table, I get an error message that the table does not exist. Yet, this does not make sense since I was able to show the same table through SHOW TABLES statement.
My guess is that SHOW TABLES lists file existence but does not check whether a file is corrupted or not. Consequently, I can list those files but not access them.
Nevertheless, it is merely a guess. I have never seen this before. Now, I cannot restart the database for testing, but every other application that uses it is running fine.
But that's just a guess, I've never seen this before.
Does anyone know why this is happening?
Example:
mysql> SHOW TABLES;
+-----------------------+
| Tables_in_database |
+-----------------------+
| TABLE_ONE |
| TABLE_TWO |
| TABLE_THREE |
+-----------------------+
mysql> SELECT * FROM TABLE_ONE;
ERROR 1146 (42S02): Table 'database.TABLE_ONE' doesn't exist
Just in case anyone still cares:
I had the same issue after copying a database directory directly using command
cp -r /path/to/my/database /var/lib/mysql/new_database
If you do this with a database that uses InnoDB tables, you will get this crazy 'table does not exist' error mentioned above.
The issue is that you need the ib* files in the root of the MySQL datadir (e.g. ibdata1, ib_logfile0 and ib_logfile1).
When I copied those it worked for me.
For me on Mac OS (MySQL DMG Installation) a simple restart of the MySQL server solved the problem. I am guessing the hibernation caused it.
I get this issue when the case for the table name I'm using is off. So table is called 'db' but I used 'DB' in select statement. Make sure the case is the same.
This error can also occur when setting lower_case_table_names to 1, and then trying to access tables that were created with the default value for that variable. In that case you can revert it to the previous value and you will be able to read the table.
I don't know the reason but in my case I solved just disabling and enabling the foreign keys check
SET FOREIGN_KEY_CHECKS=0;
SET FOREIGN_KEY_CHECKS=1;
stop mysqld
backup mysql folder: cp -a /var/lib/mysql /var/lib/mysql-backup
copy database folder from old machine to /var/lib/mysql
override ib* (ib_logfile* , ibdata ) from old database
start mysqld
dump dabase
mysqldump >dbase.mysql
stop mysql service
remove /var/lib/mysql
rename /var/lib/mysql-backup to /var/lib/mysql
start mysqld
create the database
mysqldump < dbase.mysql
Please run the query:
SELECT
i.TABLE_NAME AS table_name,
LENGTH(i.TABLE_NAME) AS table_name_length,
IF(i.TABLE_NAME RLIKE '^[A-Za-z0-9_]+$','YES','NO') AS table_name_is_ascii
FROM
information_schema.`TABLES` i
WHERE
i.TABLE_SCHEMA = 'database'
Unfortunately MySQL allows unicode and non-printable characters to be used in table name.
If you created your tables by copying create code from some document/website, there is a chance that it has zero-width-space somewhere.
I had the same problem and I searched for 2-3 days, but the solution for me was really stupid.
Restart the mysql
$ sudo service mysql restart
Now tables become accessible.
I have just spend three days on this nightmare. Ideally, you should have a backup that you can restore, then simply drop the damaged table. These sorts of errors can cause your ibdata1 to grow huge (100GB+ in size for modest tables)
If you don't have a recent backup, such as if you relied on mySqlDump, then your backups probably silently broke at some point in the past. You will need to export the databases, which of course you cant do, because you will get lock errors while running mySqlDump.
So, as a workaround, go to /var/log/mysql/database_name/ and remove the table_name.*
Then immediately try to dump the table; doing this should now work. Now restore the database to a new database and rebuild the missing table(s). Then dump the broken database.
In our case we were also constantly getting mysql has gone away messages at random intervals on all databases; once the damaged database were removed everything went back to normal.
Try to run sql query to discard tablespace before copying idb-file:
ALTER TABLE mydatabase.mytable DISCARD TABLESPACE;
Copy idb-file
ALTER TABLE mydatabase.mytable IMPORT TABLESPACE;
Restart MySql
O.k. this is going to sound pretty absurd, but humor me.
For me the problem got resolved when I changed my statement to this :
SELECT * FROM `table`
I made two changes
1.) Made the table name lower case - I know !!
2.) Used the specific quote symbol = ` : It's the key above your TAB
The solution does sound absurd, but it worked and it's Saturday evening and I've been working since 9 a.m. - So I'll take it :)
Good luck.
What worked for me, was just dropping the table, even though it didnt exist. Then I re created the table and repopulated from an sql dump done previously.
There must be some metabase of table names, and it was most likely still existing in there till i dropped it.
Had a similar problem with a ghost table. Thankfully had an SQL dump from before the failure.
In my case, I had to:
Stop mySQL
Move ib* files from /var/mysql off to a backup
Delete /var/mysql/{dbname}
Restart mySQL
Recreate empty database
Restore dump file
NOTE: Requires dump file.
I had this problem after upgrading WAMP but having no database backup.
This worked for me:
Stop new WAMP
Copy over database directories you need and ibdata1 file from old WAMP installation
Delete ib_logfile0 and ib_logfile1
Start WAMP
You should now be able to make backups of your databases. However after your server restarts again you will still have problems. So now reinstall WAMP and import your databases.
After having to reinstall MySQL I had this same problem, it seems that during the install, some configuration files that store data about the InnoDB log files, these files ib_logfile* (they are log files right?), are overwriten. To solve this problem I just deleted the ib_logfile* files.
Do mysqldump to database:
mysqldump -u user -ppass dbname > D:\Back-ups\dbname.sql
Restore database
mysql -u user -ppass dbname < D:\Back-ups\dbname.sql
Now all tables in database were restored completely. Try..
SELECT * FROM dbname.tablename;
It appears that the issue has to do (at least in mine and a few others) with invalid (corrupt?) innodb log files. Generally speaking, they simply need to be recreated.
Here are solutions, most of which require a restart of mysql.
Recreate your log files (Delete and restart mysql)
Resize your log files (MySql 5.6+ will regenerate the file for you)
If you are doing some type of a data migration, make sure you have correctly migrated the right file and given it permissions as others have already stated
Check permissions of your data and log files, that mysql is owner of both
If all else fails, you will likely have to recreate the database
In my case, i had defined a trigger on the table and then was trying to insert the row in table. seems like, somehow trigger was erroneous, and hence insert was giving error, table doesn't exist.
Copy only ibdata1 file from your old data directory. Do not copy ib_logfile1 or ib_logfile0 files. That will cause MySQL to not start anymore.
Came cross same problem today. This is a mysql "Identifier Case Sensitivity" issue.
Please check corresponding data file. It is very likely that file name is in lower case on file system but table name listed in "show tables" command is in upper case. If system variable "lower_case_table_names" is 0, the query will return "table not exist" because name comparisons are case sensitive when "lower_case_table_names" is 0.
Its possible you have a hidden character in your table name. Those don't show up when you do a show tables. Can you do a "SHOW CREATE TABLE TABLE_ONE" and tab complete the "TABLE_ONE" and see if it puts in any hidden characters. Also, have you tried dropping and remaking the tables. Just to make sure nothing is wrong with the privileges and that there are no hidden characters.
I installed MariaDB on new computer,
stopped Mysql service
renamed data folder to data-
I solved my problem copying just
Mysql\data\table_folders and ibdata1
from crashed HD MySql data Folder to the new installed mysql data folder.
I Skipped ib_logfile0 and ib_logfile1 (otherwise the server did not start service)
Started mysql service.
Then server is running.
Same exact problem after TimeMachine backup import. My solution was to stop the MySQL server and fix read-write permissions on the ib* files.
One other answer I think is worth bringing up here (because I came here with that same problem and this turned out to be the answer for me):
Double check that the table name in your query is spelled exactly the same as it is in the database.
Kind of an obvious, newbie thing, but things like "user" vs "users" can trip people up and I thought it would be a helpful answer to have in the list here. :)
In my case, when I was importing the exported sql file, I was getting an error like table doesn't exist for the create table query.
I realized that there was an underscore in my database name and mysql was putting an escape character just before that.
So I removed that underscore in the database name, everything worked out.
Hope it helps someone else too.
Here is another scenario (version upgrade):
I reinstalled my OS (Mac OS El Captain) and installed a new version of mysql (using homebrew). The installed version (5.7) happened to be newer than my previous one. Then I copied over the tables, including the ib* files, and restarted the server. I could see the tables in mysql workbench but when I tried to select anything, I got "Table doesn't exist".
Solution:
stop the mysql server e.g. mysql.server stop or brew services stop mysql
start the server using mysqld_safe --user=mysql --datadir=/usr/local/var/mysql/ (change path as needed)
run mysql_upgrade -u root -p password (in another terminal window)
shut down the running server mysqladmin -u root -p password shutdown
restart the server in normal mode mysql.server start or brew services start mysql
Relevant docs are here.
My table had somehow been renamed to ' Customers' i.e. with a leading space
This meant
a) queries broke
b) the table didn't appear where expected in the alphabetical order of my tables, which in my panic meant I couldn't see it!
RENAME TABLE ` Customer` TO `Customer`;
In my case it was SQLCA.DBParm parameter.
I used
SQLCA.DBParm = "Databse = "sle_database.text""
but it must be
SQLCA.DBParm = "Database='" +sle_database.text+ "'"
Explaination :
You are going to combine three strings :
1. Database=' - "Database='"
2. (name of the database) - +sle_database.text+
3. ' - "'" (means " ' " without space)
Don't use spaces in quatermarks.
Thank to my colleague Jan.
Go to :xampp\mysql\data\dbname
inside dbname have tablename.frm and tablename.ibd file. remove it
and restart mysql and try again.
I had the same issue in windows.
In addition to copying the ib* files and the mysql directory under thd data directory, I also had to match the my.ini file.
The my.ini file from my previous installation did not have the following line:
innodb-page-size=65536
But my new installation did. Possibly because I did not have that option in the older installer.
I removed this and restarted the service and the tables worked as expected.
In short, make sure that the new my.ini file is a replica of the old one, with the only exception being the datadir, the plugin-dir and the port#, depending upon your new installation.

How do I locate my new mySQL database where I want it?

I'm on Windows using mySQL Workbench when I absolutely have to, otherwise ADO.
I'm experienced with Jet databases where you just create your mdb file, put it wherever you want whenever you want, and open the database with an ADO connection string containing the path to the database.
Now I've got to do this wretched mySQL thing ... for some reason I don't understand there's this Data directory where all the databases go and you can't change that when creating the database(?).
So I create my database as a shell (1 junk table to be deleted later, no records) and it's stuck in this worthless Data directory. Now I want to copy/paste this shell to where I really want it, and start working on it through ADO to create my "real" database ... but it doesn't work; my ADO connection string contains the new path and the connection opens with no errors, but all operations only change the copy in the Data directory.
Yes I have searched this topic, and the only "solutions" I see are to change the default Data directory in the ini file ... this seems silly and unworkable; what if I want to create another database and put it somewhere else?
Can someone please shed some light here?
Once you connect to the MySQL database as a user that can create databases, usually the root user after install, you can just write:
CREATE DATABASE my_database;
and that database will be created on the machine that's running the MySQL server process in the datadir that MySQL is using. There are default locations for these things, but you probably won't need to worry about them. You don't need to worry about where the files end up going as the first commenter says.
Here is the information for finding your my.cnf file on Windows. Once you find that file, update your datadir to the location that you want like this:
datadir="C:\New Data\Path"
and then stop your MySQL server and move your files. Restart the MySQL server after you copy all of the files in your current datadir to it. You can find your current datadir with the following command (connected to the server as the root user):
SHOW VARIABLES LIKE '%datadir%';
Make sure to stop the server before moving your files.
The CREATE TABLE documentation shows that you can create a table in a TABLESPACE that's outside of your datadir. First create a tablespace like the following:
CREATE TABLESPACE my_tablespace ADD DATAFILE 'C:\my_space';
which needs to be a single file if you want to use the InnoDB engine. You can then create tables in that table space by specifying it in your table's creation like:
CREATE TABLE new_table (a INT) TABLESPACE my_tablespace;
I haven't done this before, but it should work.

MySQL > Table doesn't exist. But it does (or it should)

I changed the datadir of a MySQL installation and all the bases moved correctly except for one.
I can connect and USE the database. SHOW TABLES also returns me all the tables correctly, and the files of each table exists on the MySQL data directory.
However, when I try to SELECT something from the table, I get an error message that the table does not exist. Yet, this does not make sense since I was able to show the same table through SHOW TABLES statement.
My guess is that SHOW TABLES lists file existence but does not check whether a file is corrupted or not. Consequently, I can list those files but not access them.
Nevertheless, it is merely a guess. I have never seen this before. Now, I cannot restart the database for testing, but every other application that uses it is running fine.
But that's just a guess, I've never seen this before.
Does anyone know why this is happening?
Example:
mysql> SHOW TABLES;
+-----------------------+
| Tables_in_database |
+-----------------------+
| TABLE_ONE |
| TABLE_TWO |
| TABLE_THREE |
+-----------------------+
mysql> SELECT * FROM TABLE_ONE;
ERROR 1146 (42S02): Table 'database.TABLE_ONE' doesn't exist
Just in case anyone still cares:
I had the same issue after copying a database directory directly using command
cp -r /path/to/my/database /var/lib/mysql/new_database
If you do this with a database that uses InnoDB tables, you will get this crazy 'table does not exist' error mentioned above.
The issue is that you need the ib* files in the root of the MySQL datadir (e.g. ibdata1, ib_logfile0 and ib_logfile1).
When I copied those it worked for me.
For me on Mac OS (MySQL DMG Installation) a simple restart of the MySQL server solved the problem. I am guessing the hibernation caused it.
I get this issue when the case for the table name I'm using is off. So table is called 'db' but I used 'DB' in select statement. Make sure the case is the same.
This error can also occur when setting lower_case_table_names to 1, and then trying to access tables that were created with the default value for that variable. In that case you can revert it to the previous value and you will be able to read the table.
I don't know the reason but in my case I solved just disabling and enabling the foreign keys check
SET FOREIGN_KEY_CHECKS=0;
SET FOREIGN_KEY_CHECKS=1;
stop mysqld
backup mysql folder: cp -a /var/lib/mysql /var/lib/mysql-backup
copy database folder from old machine to /var/lib/mysql
override ib* (ib_logfile* , ibdata ) from old database
start mysqld
dump dabase
mysqldump >dbase.mysql
stop mysql service
remove /var/lib/mysql
rename /var/lib/mysql-backup to /var/lib/mysql
start mysqld
create the database
mysqldump < dbase.mysql
Please run the query:
SELECT
i.TABLE_NAME AS table_name,
LENGTH(i.TABLE_NAME) AS table_name_length,
IF(i.TABLE_NAME RLIKE '^[A-Za-z0-9_]+$','YES','NO') AS table_name_is_ascii
FROM
information_schema.`TABLES` i
WHERE
i.TABLE_SCHEMA = 'database'
Unfortunately MySQL allows unicode and non-printable characters to be used in table name.
If you created your tables by copying create code from some document/website, there is a chance that it has zero-width-space somewhere.
I had the same problem and I searched for 2-3 days, but the solution for me was really stupid.
Restart the mysql
$ sudo service mysql restart
Now tables become accessible.
I have just spend three days on this nightmare. Ideally, you should have a backup that you can restore, then simply drop the damaged table. These sorts of errors can cause your ibdata1 to grow huge (100GB+ in size for modest tables)
If you don't have a recent backup, such as if you relied on mySqlDump, then your backups probably silently broke at some point in the past. You will need to export the databases, which of course you cant do, because you will get lock errors while running mySqlDump.
So, as a workaround, go to /var/log/mysql/database_name/ and remove the table_name.*
Then immediately try to dump the table; doing this should now work. Now restore the database to a new database and rebuild the missing table(s). Then dump the broken database.
In our case we were also constantly getting mysql has gone away messages at random intervals on all databases; once the damaged database were removed everything went back to normal.
Try to run sql query to discard tablespace before copying idb-file:
ALTER TABLE mydatabase.mytable DISCARD TABLESPACE;
Copy idb-file
ALTER TABLE mydatabase.mytable IMPORT TABLESPACE;
Restart MySql
O.k. this is going to sound pretty absurd, but humor me.
For me the problem got resolved when I changed my statement to this :
SELECT * FROM `table`
I made two changes
1.) Made the table name lower case - I know !!
2.) Used the specific quote symbol = ` : It's the key above your TAB
The solution does sound absurd, but it worked and it's Saturday evening and I've been working since 9 a.m. - So I'll take it :)
Good luck.
What worked for me, was just dropping the table, even though it didnt exist. Then I re created the table and repopulated from an sql dump done previously.
There must be some metabase of table names, and it was most likely still existing in there till i dropped it.
Had a similar problem with a ghost table. Thankfully had an SQL dump from before the failure.
In my case, I had to:
Stop mySQL
Move ib* files from /var/mysql off to a backup
Delete /var/mysql/{dbname}
Restart mySQL
Recreate empty database
Restore dump file
NOTE: Requires dump file.
I had this problem after upgrading WAMP but having no database backup.
This worked for me:
Stop new WAMP
Copy over database directories you need and ibdata1 file from old WAMP installation
Delete ib_logfile0 and ib_logfile1
Start WAMP
You should now be able to make backups of your databases. However after your server restarts again you will still have problems. So now reinstall WAMP and import your databases.
After having to reinstall MySQL I had this same problem, it seems that during the install, some configuration files that store data about the InnoDB log files, these files ib_logfile* (they are log files right?), are overwriten. To solve this problem I just deleted the ib_logfile* files.
Do mysqldump to database:
mysqldump -u user -ppass dbname > D:\Back-ups\dbname.sql
Restore database
mysql -u user -ppass dbname < D:\Back-ups\dbname.sql
Now all tables in database were restored completely. Try..
SELECT * FROM dbname.tablename;
It appears that the issue has to do (at least in mine and a few others) with invalid (corrupt?) innodb log files. Generally speaking, they simply need to be recreated.
Here are solutions, most of which require a restart of mysql.
Recreate your log files (Delete and restart mysql)
Resize your log files (MySql 5.6+ will regenerate the file for you)
If you are doing some type of a data migration, make sure you have correctly migrated the right file and given it permissions as others have already stated
Check permissions of your data and log files, that mysql is owner of both
If all else fails, you will likely have to recreate the database
In my case, i had defined a trigger on the table and then was trying to insert the row in table. seems like, somehow trigger was erroneous, and hence insert was giving error, table doesn't exist.
Copy only ibdata1 file from your old data directory. Do not copy ib_logfile1 or ib_logfile0 files. That will cause MySQL to not start anymore.
Came cross same problem today. This is a mysql "Identifier Case Sensitivity" issue.
Please check corresponding data file. It is very likely that file name is in lower case on file system but table name listed in "show tables" command is in upper case. If system variable "lower_case_table_names" is 0, the query will return "table not exist" because name comparisons are case sensitive when "lower_case_table_names" is 0.
Its possible you have a hidden character in your table name. Those don't show up when you do a show tables. Can you do a "SHOW CREATE TABLE TABLE_ONE" and tab complete the "TABLE_ONE" and see if it puts in any hidden characters. Also, have you tried dropping and remaking the tables. Just to make sure nothing is wrong with the privileges and that there are no hidden characters.
I installed MariaDB on new computer,
stopped Mysql service
renamed data folder to data-
I solved my problem copying just
Mysql\data\table_folders and ibdata1
from crashed HD MySql data Folder to the new installed mysql data folder.
I Skipped ib_logfile0 and ib_logfile1 (otherwise the server did not start service)
Started mysql service.
Then server is running.
Same exact problem after TimeMachine backup import. My solution was to stop the MySQL server and fix read-write permissions on the ib* files.
One other answer I think is worth bringing up here (because I came here with that same problem and this turned out to be the answer for me):
Double check that the table name in your query is spelled exactly the same as it is in the database.
Kind of an obvious, newbie thing, but things like "user" vs "users" can trip people up and I thought it would be a helpful answer to have in the list here. :)
In my case, when I was importing the exported sql file, I was getting an error like table doesn't exist for the create table query.
I realized that there was an underscore in my database name and mysql was putting an escape character just before that.
So I removed that underscore in the database name, everything worked out.
Hope it helps someone else too.
Here is another scenario (version upgrade):
I reinstalled my OS (Mac OS El Captain) and installed a new version of mysql (using homebrew). The installed version (5.7) happened to be newer than my previous one. Then I copied over the tables, including the ib* files, and restarted the server. I could see the tables in mysql workbench but when I tried to select anything, I got "Table doesn't exist".
Solution:
stop the mysql server e.g. mysql.server stop or brew services stop mysql
start the server using mysqld_safe --user=mysql --datadir=/usr/local/var/mysql/ (change path as needed)
run mysql_upgrade -u root -p password (in another terminal window)
shut down the running server mysqladmin -u root -p password shutdown
restart the server in normal mode mysql.server start or brew services start mysql
Relevant docs are here.
My table had somehow been renamed to ' Customers' i.e. with a leading space
This meant
a) queries broke
b) the table didn't appear where expected in the alphabetical order of my tables, which in my panic meant I couldn't see it!
RENAME TABLE ` Customer` TO `Customer`;
In my case it was SQLCA.DBParm parameter.
I used
SQLCA.DBParm = "Databse = "sle_database.text""
but it must be
SQLCA.DBParm = "Database='" +sle_database.text+ "'"
Explaination :
You are going to combine three strings :
1. Database=' - "Database='"
2. (name of the database) - +sle_database.text+
3. ' - "'" (means " ' " without space)
Don't use spaces in quatermarks.
Thank to my colleague Jan.
Go to :xampp\mysql\data\dbname
inside dbname have tablename.frm and tablename.ibd file. remove it
and restart mysql and try again.
I had the same issue in windows.
In addition to copying the ib* files and the mysql directory under thd data directory, I also had to match the my.ini file.
The my.ini file from my previous installation did not have the following line:
innodb-page-size=65536
But my new installation did. Possibly because I did not have that option in the older installer.
I removed this and restarted the service and the tables worked as expected.
In short, make sure that the new my.ini file is a replica of the old one, with the only exception being the datadir, the plugin-dir and the port#, depending upon your new installation.

How can I recover MySQL tables from data files?

I've got a database (all MyISAM tables) and the machine where MySQL was running is no longer bootable. However, we have all the MySQL data files from the data directory. How can I restore the data from the MYD and FRM files, or whatever other files I should be looking at in the data directory?
I've been doing some searching on this and it sounds like for MyISAM I should just be able to copy the database subdirectory from the old MySQL data directory to the new MySQL data directory. However, that's not working for me. A database with the name of the database I'm trying to recover shows up in the list of databases in phpMyAdmin, but all the tables show "in use" and have no information (e.g., number of rows, number of bytes, column information, etc.). Any operation on those tables (e.g., SELECT * FROM {table}, REPAIR {table}, CHECK {table}) returns a "no such table" error.
One of the tools I ran across in my search is DBACentral by MicroOLAP. It's got component that's supposed to restore data from FRM/MYD files, but when I tried to run it, it didn't list any tables that it could recover from my FRM/MYD files.
This is on a developer workstation that's running Vista Business 32bit. MySQL version is 5.0.27. After fixing the machine, I went and got the exact same version of MySQL (v5.0.27), thinking that if I'm just going to drop in the binary data files I should do it with the same version of MySQL. It still didn't work.
Any insights would be greatly appreciated... thanks!
-Josh
Install the same version of mysql.
Remove mysql directory from data directory of the server and copy it from the crashed server. This is the key element
copy directory of database you want to recover into data directory of new server
start mysql.
switch to mysql database: USE mysql; and run REPAIR TABLE <table name> on every table.
Do the same with database you want to recover
tip: make sure the 2 directories have the same permissions like data directory
If you did not save mysql database (mysql directory in your old server's data dir, then you can try to:
create database with the same name as database you want to recover.
Then you can create each table (it would be good to use the same structure - you'd have bigger chance of recovery).
then stop mysql server and delete files from database directory and overwrite them with files from old server
start mysql and repair each table.
I wound up giving up. I think the answer is that, with my particular version of MySQL, this doesn't work. Hopefully things have improved since then.