MySQL: [Err] 1146 - Unknown error 1146 - mysql

I'm using MySQL 5.7.13. I'm getting above error if a table doesn't exist. Not only this whatever the error is I'm getting only 'unknown error'. Can any let me know that how to make MySQL to display actual error i.e. Table doesn't exist.
Thanks

Having the same issue with a raw download binary.
Comes with this error when trying to run any mysqld:
[ERROR] Can't find error-message file
Solved it by specifying --lc_messages_dir.
Examples:
mysqld --console --datadir ~/.mysqldata --lc_messages_dir=$MYSQL_HOME/share/english --initialize-insecure
mysqld --console --datadir ~/.mysqldata --lc_messages_dir=$MYSQL_HOME/share/english

1.You should probably look if your table exist.
2. If you are inserting data from one table to another table with a statement like, Insert into table_A select * from table_B, in this if there is any column mismatch, you will encounter this error.

Following two steps will help you out:
if you have copied the mysql data , Go to the original directory xampp/mysql/data ( or whatever is relevant to your OS) , and copy all the files starting with word ib, like ib_logfil0 etc. and paste to the new directory.
Go to mysql command line, and run this command:
mysql_upgrade

Related

Unable to start mysql via XAMPP - mysql\db crashed

I have successfully been using XAMPP on my windows 10 PC to run a website that I am working on locally until today.
When I try to start MySQL, it fails. The error logs state:
mysqld.exe: Table '.\mysql\db' is marked as crashed and last (automatic?) repair failed
Fatal error: Can't open and lock privilege tables: Table '.\mysql\db' is marked as crashed and last (automatic?) repair failed
As I try to fix this, I attempted the following:
mysqlcheck --repair --use-frm --all-databases
but this gives me the following error:
Got error: 2002: Can't connect to MySQL server on 'localhost' (10061) when trying to connect
Which I guess makes sense because the mysql service isnt able to run.
I have also tried running the following from this directory: c:\xampp\mysql\data. Doing this results in an error saying 'db' doesnt exist.:
myisamchk -r db
I noticed that i have a db.MAD file that is rather large 174,616K, so not sure if that is the problem.
I ran into the same problem here is what I did:
Find and open the 'my.ini' file with Notepad. (Mine is at c:\xampp\mysql\bin\my.ini )
Insert 'skip-grant-tables' in the 'my.ini' file on a new line following the label '[mysqld]' and save. You will remove this after the problem is fixed.
Now mySQL you can start XAMPP from the control panel.
Start phpMyAdmin from your browser and select the table 'db' from the database 'mysql'
(Select 'mysql' from left panel then check 'db' in right hand panel).
Beneath from the 'With selected' dropdown, run 'analyze' (it should say that it is corrupted). Then select again and run 'repair table'.
Find the 'my.ini' file again and open with Notepad.
Remove 'skip-grant-tables' in the 'my.ini' file and save.
Problem should be fixed and you should be able to start XAMPP normally which will start MySQL normally.

Why am I getting a MySQL error in cmd when trying to change my password?

I am trying to change my MySQL password. However, when I go into cmd and type the directory of my my.ini file, it tells me.
mysqld: [ERROR] Could not open required defaults file: Windows-SSD(C:)\ProgramData\MySQL\MySQL Server 5.7\my.ini
mysqld: [ERROR] Fatal error in defaults handling. Program aborted!
Please help, I am following this tutorial. I am sure that the directory is correct (I copied it).
Looks like your MySQL installation is missing my.ini file. Check if it's there.
It was a problem in 5.5 version (I'm not sure about 5.7), but you can try the solution from this this topic.

Mysql table repair failed: "Can't create new tempfile"

I run a WordPress website. Today I found that wp_posts table is crashed. When I tried to repair the table, I got the following error:
REPAIR TABLE wp_posts;
error Can't create new tempfile: './[databasename]/wp_posts.TMD'
repair status Operation failed
I tried to run the following command in shell:
myisamchk -r -f wp_posts.MYI
error: File 'wp_posts.MYI' doesn't exist
Can you please tell me what else I can try to fix this problem?
Turned out that "myisamchk -r -f wp_posts.MYI" was the correct solution. I just had to go to the data folder.
In my CentOS system, I changed directory to /var/lib/mysql/[database]/and found wp_posts.MYI
After removing this file, repair was successful.
Try stopping your service using the following command sudo service mysql stop
Now do the repair check myisamchk -r -f -o /var/lib/mysql/DatabaseName/wp_posts
Start your service and enjoy it!
It works for me
Try adding the following line to your wp-config.php file:
define( 'WP_ALLOW_REPAIR', true );
Then go to:
/wp-admin/maint/repair.php
That should take effect and automatically repair your crashed table.
For mariaDB and some other combination of OS and DB version, the file may also be located under /config/databases/[DATABASE].
Try to run as root (sudo su):
service mysql stop
myisamchk -rf /config/databases/[databasename]/wp_posts.MYI
service mysql start
I just had the same trouble. The problem was the .TMD file already existed and mysqlrepair refused to overwrite it. I removed the .TMD file and the mysqlrepair worked famously. I had to stop the process attempting to use the crashed table, then run the repair.
When I saw this error in phpMyadmin, I got around it by navigating to /var/lib/mysql/[database]/ and deleting the TMD file for the table I was trying to repair (not the MYI file as stated in the explanation above).
When I tried getting rid of the MYI file, the repair operation didn't work.

Cannot use database tables after reinstalling wampserver

I have just reinstalled WAMPSERVER without backing-up the data folder of MYSQL under WAMPSERVER, with the understanding that uninstalling and re-installing WAMPSERVER would leave the data directory of MYSQL intact as it is. This was a re-installation of the same WAMPSERVER version.
So now I login to MYSQL, can see all databases and tables from previous WAMPSERVER using SHOW DATABASES, and SHOW TABLES IN myDb. But trying SHOW COLUMNS IN myTable or further attempt to access the data in these tables fails, giving the error:
ERROR 1146 (42S02): Table 'myDb.myTable' doesn't exist
and the logfile:
2013-10-08 14:42:23 1072 [Warning] InnoDB: Cannot open table myDB/myTable from the internal data dictionary of InnoDB though the .frm file for the table exists.
try an CREATE if not exists query, see what output this gives.

mysqldump: Can't create/write to file error from amazon RDS

I am attempting to dump a database running on Amazon's RDS service, mysql version 5.5.27. Here's the command I'm running:
my-ec2-instance# mysqldump -hec2-xx-xx-xx-xx.compute-1.amazonaws.com -uuser -pwhatever mydb
I get the following error:
mysqldump: Couldn't execute 'show fields from `MyTable`': Can't create/write to file '/tmp/#sql_1405_0.MYI' (Errcode: 2) (1)
So, since the error message says its failing on "show fields", I tried to execute "Show fields from MyTable" from the mysql interpreter directly. I get what appears to be a file issue:
mysql> show fields from MyTable;
ERROR 1 (HY000): Can't create/write to file '/tmp/#sql_1405_0.MYI' (Errcode: 2)
however, on the same EC2 instance that I am getting this error on, I can create this file and delete it:
my-ec2-instance# touch /tmp/#sql_1405_0.MYI; ls /tmp/#sql*;rm /tmp/#sql_1405_0.MYI
/tmp/#sql_1405_0.MYI
rm: remove regular empty file `/tmp/#sql_1405_0.MYI'?
I've tried the same thing from my local machine, and I get the same result. Googling this has not borne fruit. How can I prevent this error from occurring?
As Mike Brant suggested, I resized the instance on EC2, which forced it to switch machines, re-sized it back to the former size, and the problem no longer occurred.
I'm still not clear on the root cause, but it does appear to be down to some kind of bad state or misconfiguration specific to the EC2 instance I was using at the time.