I have accidentally deleted a .frm file for a test table. The problem is that I can not drop this table and remove it from information_schema.
select * from information_schema.tables where table_name like 'testtesttest';
+---------------+--------------+--------------+------------+--------+---------+------------+------------+----------------+-------------+-----------------+--------------+-----------+----------------+-------------+-------------+------------+-----------------+----------+----------------+----------------------------------------------------------+
| TABLE_CATALOG | TABLE_SCHEMA | TABLE_NAME | TABLE_TYPE | ENGINE | VERSION | ROW_FORMAT | TABLE_ROWS | AVG_ROW_LENGTH | DATA_LENGTH | MAX_DATA_LENGTH | INDEX_LENGTH | DATA_FREE | AUTO_INCREMENT | CREATE_TIME | UPDATE_TIME | CHECK_TIME | TABLE_COLLATION | CHECKSUM | CREATE_OPTIONS | TABLE_COMMENT |
+---------------+--------------+--------------+------------+--------+---------+------------+------------+----------------+-------------+-----------------+--------------+-----------+----------------+-------------+-------------+------------+-----------------+----------+----------------+----------------------------------------------------------+
| def | report | testtesttest | BASE TABLE | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | Can't find file: './report/testtesttest.frm' (errno: 13) |
+---------------+--------------+--------------+------------+--------+---------+------------+------------+----------------+-------------+-----------------+--------------+-----------+----------------+-------------+-------------+------------+-----------------+----------+----------------+----------------------------------------------------------+
drop table report.testtesttest;
ERROR 1051 (42S02): Unknown table 'testtesttest'
Is there a way to tell mysql that such a table no longer exists?
Looks like that the following steps help:
touch /var/lib/mysql/report/testtesttest.{frm,ibd}
chown mysql:mysql /var/lib/mysql/report/testtesttest.frm
restart mysql
drop table report.testtesttest;
Related
I have table ip_per_nat_vlan, innodb format. When I give truncate table, table is empty.
Then I have php script, which fill data into this table.
When is this script finished without errors (simple insert statemets) situation is following:
select * from ip_per_nat_vlan;
Empty set (0.00 sec)
.
select count(*) from ip_per_nat_vlan;
+----------+
| count(*) |
+----------+
| 0 |
+----------+
1 row in set (0.00 sec)
.
show table status;
+----------------------------------+--------+---------+------------+----------+----------------+-------------+-----------------+--------------+------------+----------------+---------------------+---------------------+------------+-----------------+----------+----------------+---------+
| Name | Engine | Version | Row_format | Rows | Avg_row_length | Data_length | Max_data_length | Index_length | Data_free | Auto_increment | Create_time | Update_time | Check_time | Collation | Checksum | Create_options | Comment |
+----------------------------------+--------+---------+------------+----------+----------------+-------------+-----------------+--------------+------------+----------------+---------------------+---------------------+------------+-----------------+----------+----------------+---------+
| ip_per_nat_vlan | InnoDB | 10 | Dynamic | 141291 | 100 | 14172160 | 0 | 6832128 | 25165824 | 143563 | 2017-12-24 16:26:40 | 2018-06-13 09:01:33 | NULL | utf8_unicode_ci | NULL |
MySQL says, that there should be 14172160 rows, but I dont see any. Where could be a problem? Transactions? But I dont see any running thread and no any fault.
Thank you. D
Structure of table is:
+------------+--------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+------------+--------------+------+-----+---------+----------------+
| id | int(11) | NO | PRI | NULL | auto_increment |
| ipAddress | varchar(255) | NO | UNI | NULL | |
| nat | int(11) | NO | | NULL | |
| vlan | int(11) | NO | | NULL | |
| district | varchar(255) | YES | | NULL | |
| idOblasti | int(11) | YES | | NULL | |
| type | varchar(255) | NO | | NULL | |
| macAddress | varchar(255) | NO | | NULL | |
+------------+--------------+------+-----+---------+----------------+
There are various ways to "count" rows in a table.
The normal way. Just count them.
select count(*) as table_rows from table_name ;
Accuracy: 100% accurate count at the time of the query is run.
using the information_schema tables
select table_rows
from information_schema.tables
where table_schema = 'database_name'
and table_name = 'table_name' ;
Accuracy: Only an approximation. If the table is the target of frequent inserts and deletes, the result can be way off the actual count. This can be improved by running ANALYZE TABLE more often.
Efficiency: Very good, it doesn't touch the table at all.
As count option is 100% accurate, your table doesn't contain any data.
Check your code and default commit option of MySQL.
Looks like you are inserting rows, but not committing them, check your index length.
Check more details here
https://dba.stackexchange.com/questions/151769/mysql-difference-between-using-count-and-information-schema-tables-for-coun
First thing, I am not sure how mysql run this line and produce the result
select count() from ip_per_nat_vlan
count() will return [Err] 1064.
count(*) or else a field name should be mentioned inside.
Out of the sudden I am getting a weird error on my mysql database tables.
SELECT * FROM mytable
returns:
ERROR 1932 (42S02): Table 'mydb.mytable' doesn't exist in engine
I can confirm that the tables do indeed exist on local file system and show tables; does indeed return the tables I am interested in.
show tables;
+-----------------+
| Tables_in_mydb |
+-----------------+
| presets |
| mytable |
+-----------------+
And the select:
select * from mytable;
Table 'mydb.mytable' doesn't exist in engine.
Error makes absolute no sense and I've been working with this tables a couple of days ago without any problems. I haven't moved the tables. What should I do?
Before that error above showed up I was getting an error:
Access denied for user 'root'#'localhost' (using password: YES),
but I successfully updated the password. I have no idea what triggered this error because I haven't played with passwords. However, when I tried to fix this error I have set permissions on /Applications/XAMPP/xamppfiles/var/mysql to read/write to everyone.
UPDATE:
show table status gives back a really weird outout:
+-----------------+--------+---------+------------+------+----------------+-------------+-----------------+--------------+-----------+----------------+---------------------+-------------+------------+-------------------+----------+----------------+------------------------------------------------------+
| Name | Engine | Version | Row_format | Rows | Avg_row_length | Data_length | Max_data_length | Index_length | Data_free | Auto_increment | Create_time | Update_time | Check_time | Collation | Checksum | Create_options | Comment |
+-----------------+--------+---------+------------+------+----------------+-------------+-----------------+--------------+-----------+----------------+---------------------+-------------+------------+-------------------+----------+----------------+------------------------------------------------------+
| preset | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | Table 'mydb.preset' doesn't exist in engine |
| mytable | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | Table 'mydb.mytable' doesn't exist in engine |
The SHOW TABLES result looks a little off. The box has a bit more space on the mytable line. Is it possible there's an invisible character in your tablename somehow? Maybe you created it wrong?
I have a strange problem with a particular database:
mysql> update person set last_name=null where first_name='john';
ERROR 1713 (HY000): Undo log record is too big.
What can be the problem?
(I've already googled quite a log)
mysql 5.7.20 installed with brew on Mac OSX 10.12.6.
show table status where name = 'person'
-> ;
+--------------------+--------+---------+------------+--------+----------------+-------------+-----------------+--------------+-----------+----------------+---------------------+---------------------+------------+--------------------+----------+----------------+---------+
| Name | Engine | Version | Row_format | Rows | Avg_row_length | Data_length | Max_data_length | Index_length | Data_free | Auto_increment | Create_time | Update_time | Check_time | Collation | Checksum | Create_options | Comment |
+--------------------+--------+---------+------------+--------+----------------+-------------+-----------------+--------------+-----------+----------------+---------------------+---------------------+------------+--------------------+----------+----------------+---------+
| person | InnoDB | 10 | Dynamic | 650918 | 4322 | 2813853696 | 0 | 1369833472 | 6291456 | NULL | 2017-09-12 14:31:20 | 2017-10-24 12:37:03 | NULL | utf8mb4_unicode_ci | NULL | | |
+--------------------+--------+---------+------------+--------+----------------+-------------+-----------------+--------------+-----------+----------------+---------------------+---------------------+------------+--------------------+----------+----------------+---------+
1 row in set (0.00 sec)
So here is the table status of my test table:
+------+--------+---------+------------+--------+----------------+-------------+-----------------+--------------+-----------+----------------+---------------------+-------------+------------+-----------------+----------+----------------+---------+
| Name | Engine | Version | Row_format | Rows | Avg_row_length | Data_length | Max_data_length | Index_length | Data_free | Auto_increment | Create_time | Update_time | Check_time | Collation | Checksum | Create_options | Comment |
+------+--------+---------+------------+--------+----------------+-------------+-----------------+--------------+-----------+----------------+---------------------+-------------+------------+-----------------+----------+----------------+---------+
| TEST | InnoDB | 10 | Compact | 172713 | 1175 | 203096064 | 202309632 | 0 | 5242880 | 181935 | 2015-07-21 23:52:24 | NULL | NULL | utf8_general_ci | NULL | | |
Table is created with:
CREATE TABLE TEST ( id INT(6) UNSIGNED AUTO_INCREMENT PRIMARY KEY, att VARCHAR(1000) NOT NULL);
I heard from some one that Max_data_length used to be a fixed value and it is usually 4gb. But in later version of mysql they change the definition of Max_data_length. So now Max_data_length will grow as you insert more data (just like data_length).
I am wondering whats the new definition of Max_data_length and how is it different from Data_length?
Thanks!
Erben
I uploaded a joomla website to my database some time ago. Now I would like to know what the exact date is that I uploaded the website. Is there a way to find this out in the database?
A quick way is to check the create_time or update_time when you execute this command:
show table status;
like the following example:
+--------------------+--------+---------+------------+------+----------------+-------------+------------------+--------------+-----------+----------------+---------------------+---------------------+------------+-------------------+----------+----------------+---------+
| Name | Engine | Version | Row_format | Rows | Avg_row_length | Data_length | Max_data_length | Index_length | Data_free | Auto_increment | Create_time | Update_time | Check_time | Collation | Checksum | Create_options | Comment |
+--------------------+--------+---------+------------+------+----------------+-------------+------------------+--------------+-----------+----------------+---------------------+---------------------+------------+-------------------+----------+----------------+---------+
| a_table | MyISAM | 10 | Dynamic | 2 | 60 | 120 | 281474976710655 | 1024 | 0 | NULL | 2011-09-08 18:26:38 | 2011-11-07 20:38:28 | NULL | latin1_swedish_ci | NULL | | |
I am sure there is another way to go about this but you can probably look inside the "data" folder and see the creation date of the mysql data files.