I'd like to work locally on a Magento development website, rather than on a remote production website.
When I import the exported SQL, I keep running into MySQL Error 1215.
This Q&A suggests:
1) Open the exported sql file of your database and add following sql
query at the begining
SET FOREIGN_KEY_CHECKS = 0;
2) Goto the end of the file and add
SET FOREIGN_KEY_CHECKS = 1;
This allowed me to import the .SQL without running into errors.
Is it a wise move to use this workaround?
It doesn’t tell us exactly what’s wrong but at least the 1215 error tells me that the foreign key is the problem.
If you ever want to find out, why that error was , all you have to do is run below command and look for "LATEST FOREIGN KEY ERROR":
mysql> SHOW ENGINE INNODB STATUS
That will narrow it down a bit. It’s either a non-indexed parent key, or a data type mismatch.
I do this import almost daily and never have had any issues with Foreign Key Checks since I started doing the following steps.
Do your dump with mysqldump from the command line on the source machine.
Start with an empty database, drop the database and recreate it to ensure this before importing your database dump.
mysqldump is intelligent enough to dump data out of a database in the proper order and include all the commands to import the data so that it doesn't run into foreign key issues during the import.
What causes issues is that unless you start with an empty database, tables exist in the database and despite having drop table commands in the database import, there's always a number of tables in existence that have foreign key constraints. Start clean or you have to set foreign key constraints off and hope the data came in cleanly.
NOTE: If a clean commandline mysql dump will not import into an empty database without error, you need to start thinking about running the Magento database repair tool to deal with database corruption that hasn't caused your website to crash yet.
I received this error today in phpMyAdmin,
#1146 - Table 'phpmyadmin.pma__tracking' doesn't exist
nginx/1.6.2 | Database client version: libmysql - 5.5.41-MariaDB | PHP
extension: mysqli
It's rendered it inaccessible as whenever I try to create the table using SQL query I get that same error, #1146 - Table 'phpmyadmin.pma__tracking' doesn't exist.
I can't select a database or do anything in phpMyAdmin, is there a way to delete the tables manually or a workaround?
Using any SQL i.e DROP DATABASE results in, #1146 - Table 'phpmyadmin.pma__tracking' doesn't exist.
I just tested this with the phpMyAdmin I have installed and even when I deleted the table manually and got the error message, I could clear it up by logging out and logging back in again. So my first suggestion is to make sure your phpMyAdmin is rather up to date, as this feature has received some improvements in recent versions.
Next, I suggest you log out, clear your browser cache (at least as it relates to the phpMyAdmin page), and log in again.
You can either fix the table or disable that feature.
Repairing the phpMyAdmin Configuration Storage
Simply run the create_tables.sql file included in the examples or sql folder of your phpMyAdmin installation. You should edit the file if you wish to use a non-default database name or table names.
This could be more difficult if, for some reason, your phpMyAdmin still doesn't let you log in. In that case, you can either do it from the mysql command line client or disable the feature (see below) in order to gain access. That shouldn't be necessary, though; phpMyAdmin should automatically disable the feature on login if the table is missing.
Then edit config.inc.php and make sure the values assigned for each table correspond to the table names you just created. See http://docs.phpmyadmin.net/en/latest/config.html#cfg_Servers_pmadb for the list if you have any question about the default values.
Disabling the feature outright
Simply edit config.inc.php and remove the line $cfg['Servers'][$i]['tracking']. This will disable the feature entirely so that phpMyAdmin doesn't look for the tracking table.
I am trying to learn some mysql, php, apache and yii for a personal project, which will hopefully be extended to something commercial.
I'm designing the schema on MySQL workbench and forward engineering it to the local MySQL server. Everything is good up to this point. My idea is to develop and update the database right in the server and then reverse engineering or syncing it with the Workbench for seeing it in a diagram. But when I try to reverse engineer the database, none of the tables are imported (and they actually have been created by Workbench itself.
I've tried to troubleshoot the problem and created a database on server, with just one table and with just one column in it, which is in VARCHAR datatype. This database have been reverse engineered without a glitch. But when I try to add a INT and a DATETIME column to it, it bumps into a wall:
Windows version of MySQL Workbench (6.0.8)
WARNING: Mapping failed for datatype `int(11)`
WARNING: Mapping failed for datatype `datetime`
Linux version of MySQL Workbench (6.0.8)
ERROR: Line 5: SQL syntax error near 'int(11) NOT NULL,
`name` varchar(20) DEFAULT NULL,
`insertDate` datetime DEF'. Statement skipped.
(MySQL server Ver 14.14 Distrib 5.5.34 / on a Ubuntu 12.04 LTS box)
I should add table itself works perfectly fine when I try to add, update and delete rows.
Any ideas about what I'm doing wrong?
Edit- Based on peterm's response,
I've actually also tried syncing the model with database rather then reverse engineering, thats also not working (I was going to post some images, but couldn't due to low reputation). Under Source section, it shows an yellow exclamation mark and N/A, even though I've triple checked the table is there. In fact, it has been created by the MySQL Workbench itself!
After peterm's response, I've repeated the syncing process in order to take screenshots. While doing that I've noticed something else. When I try to update the table via MySQL Workbench, it throws the error:
Error parsing DDL for `test2`.`inttest`
There was an error while parsing the DDL retrieved from the server.
Do you want to view the DDL or cancel processing it?
When I click View DDL it shows the table creation script, but INT and VARCHAR keywords are in lower case.
I'm no expert, but shouldn't int's and varchars be in upper case?
And this is just in - When I try to edit the DDL on the opened window (last screenshot), MySQL workbench shuts down, and it also freezes the firefox tabs with flash player. It also shuts down my Windows virtual machine.
Since you previously created a model use Database -> Syncronize Model instead of Reverse Engineer.
In dialog Model and Database Differences choose Update Model and click Continue.
Error
SQL query:
CREATE DATABASE `information_schema` DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;
MySQL said:
View Full Image
#1044
- Access denied for user 'mydatabasenamehere'#'%' to database 'information_schema'
I've been told I don't have the right credentials/privileges. Ok. But where do I change them? The database was exported and then I changed the URL for my new site so I will have an exact copy of the original database. When I upload I get the above message.
I have access to both databases and both passwords. So where do I make the info right so I can import it without errors?
Your script is attempting to insert into system tables, which is forbidden:
Although you can select INFORMATION_SCHEMA as the default database with a USE statement, you can only read the contents of tables, not perform INSERT, UPDATE, or DELETE operations on them.
The question you should ask yourself is : why is your database backup containing these tables?
You should cut cut of information_schema, mysql and performance_schema from your dump before import.
May be it would be easier for you to make dump once again using mysqldump command utility and than restore it.
Another option it use grep, head, tail(*nix) or PowerShell (Windows) to extract database you need from your dump file.
I am using windows XP. I am creating a table in phpMyAdmin using its built-in create table feature,
my database name is ddd.
It generates the following code:
CREATE TABLE `ddd`.`mwrevision` (
`asd` INT NOT NULL AUTO_INCREMENT PRIMARY KEY ,
`sddd` INT NOT NULL
) ENGINE = INNODB;
and the following error shows up:
MySQL said:
#1146 - Table 'ddd.mwrevision' doesn't exist
What might be the problem?
I also had same problem in past. All had happend after moving database files to new location and after updating mysql server. All tables with InnoDB engine disappeared from my database. I was trying to recreate them, but mysql told me 1146: Table 'xxx' doesn't exist all the time until I had recreated my database and restarted mysql service.
I think there's a need to read about InnoDB table binaries.
I had the same problem and can't get a good tip for this over the web, so I shared this for you and for all who needs.
In my situation I copy a database (all files: frm, myd) to the data folder in MySQL data folder (using Wamp at home). All thing was OK until I want to create a table and have the error #1146 Table '...' doesn't exist!.
I use Wamp 2.1 with MySQL version 5.5.16.
My solution:
Export the database to file;
verify if exported file is really OK!!;
drop the database where I have issues;
create a new database with the same name that the last;
import the file to the database.
FOR ME IS PROBLEM SOLVED. Now I can create tables again without errors.
Restarting MySQL works fine for me.
In my case I ran this command even if the table wasn't visible in PhpMyAdmin :
DROP TABLE mytable
then
CREATE TABLE....
Worked for me !
Check filenames.
You might need to create a new database in phpmyadmin that matches the database you're trying to import.
I had the same problem. I tried to create a table in mysql and got the same error. I restarted mysql server and ran the command and was able to create/migrate table after restating.
Today i was facing same problem. I was in very difficult situation but what id did i create a table with diffrent name e.g (modulemaster was not creating then i create modulemaster1) and after creating table i just do the rename table.
I encountered the same problem today. I was trying to create a table users, and was prompted that ERROR 1146 (42S02): Table users doesn't exist, which did not make any sense, because I was just trying to create the table!!
I then tried to drop the table by typing DROP TABLE users, knowing it would fail because it did not exist, and I got an error, saying Unknown table users. After getting this error, I tried to create the table again, and magically, it successfully created the table!
My intuition is that I probably created this table before and it was not completely cleared somehow. By explicitly saying DROP TABLE I managed to reset the internal state somehow? But that is just my guess.
In short, try DROP whatever table you are creating, and CREATE it again.
As pprakash mentions above, copying the table.frm files AND the ibdata1 file was what worked for me.
In short:
Shut your DB explorer client (e.g. Workbench).
Stop the MySQL service (Windows host).
Make a safe copy of virtually everything!
Save a copy of the table file(s) (eg mytable.frm) to the schema data folder (e.g. MySQL Server/data/{yourschema}).
Save a copy of the ibdata1 file to the data folder (i.e., MySQL Server/data).
Restart the MySQL service.
Check that the tables are now accessible, queryable, etc. in your DB explorer client.
After that, all was well. (Don't forget to backup if you have success!)
Column names must be unique in the table. You cannot have two columns named asd in the same table.
run from CMD & %path%=set to mysql/bin
mysql_upgrade -u user -ppassword
Recently I had same problem, but on Linux Server. Database was crashed, and I recovered it from backup, based on simply copying /var/lib/mysql/* (analog mysql DATA folder in wamp). After recovery I had to create new table and got mysql error #1146. I tried to restart mysql, and it said it could not start. I checked mysql logs, and found that mysql simply had no access rigths to its DB files. I checked owner info of /var/lib/mysql/*, and got 'myuser:myuser' (myuser is me). But it should be 'mysql:adm' (so is own developer machine), so I changed owner to 'mysql:adm'. And after this mysql started normally, and I could create tables, or do any other operations.
So after moving database files or restoring from backups check access rigths for mysql.
Hope this helps...
The reason I was facing this was because I had two "models.py" files which contained slightly different fields.
I resolved it by:
deleting one of the models.py files
correcting references to the deleted file
then running manage.py syncdb
I got this issue after copying mytable.idb table file from another location. To fix this problem I did the following:
ALTER TABLE mydatabase.mytable DISCARD TABLESPACE;
Copy mytable.idb
ALTER TABLE mydatabase.mytable IMPORT TABLESPACE;
Restart MySql
I had the same issue. It happened after windows start up error, it seems some files got corrupted due to this. I did import the DB again from the saved script and it works fine.
I had this problem because of a trigger not working..Worked after I deleted the trigger.
In my case, MySQL's parameter; lower_case_table_names was configured = 0.
It causes queries related with using upper cases will not work.
For me it was a table name upper/lower case issue. I had to make sure that table case name matched in a delete query, table notifications was not the same as Notifications. I fixed it by matching table name case with query and what MySQLWorkbench reported.
What is wierd is that this error showed up in a worked sql statement. Don't know what caused this case sensitivity. Perhaps an auto AWS RDS update.
if you are modifying mysql bin->data dir's and after that, your database import will not works
so you need to close wamp and after that start wamp
now database import will work fine
Make sure you do not have a trigger that is trying to do something with the table mentioned in the error. I was receiving Error Code: 1146. Table 'exampledb.sys_diagnotics' doesn't exist on insert queries to another table in my production database. I exported the table schemas of my production database then searched for instances of exampledb.sys_diagnotics the schema SQL and found a debugging insert statement I had added to a table trigger in my development environment but this debug statement had been copied to production. The exampledb.sys_diagnotics table was not present on my production database. The error was resolved by removing the debug statement in my table trigger.