Database not working after MAMP update [duplicate] - php

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.

Related

Mysql restore only data

Good afternoon,
I have many old backup files (created with mysqldump) that fully backup my database (tables structure, data and procedures).
Now i have to alter a column CHAR(5) to VARCHAR(7) in a table but i want that my old backups are compatible with new structure. Can I restore only data from these old backup?
For the future I have already changed my php script to backup only data with --no-crete-info option in mysqldump.
Thanks a lot
Luca
Why don't you upload the mysql dump to PhpMyAdmin then change the column from CHAR(5) to VARCHAR(7) using the edit Structure tab. This would seem to be your easiest option if you aren't too sure how to edit the file dump.
The best way of handling this data definition change is to do it in place.
make a backup before the change.
take your application offline, so nobody's trying to hit the database.
Issue the command ALTER TABLE mytable MODIFY mycolumn VARCHAR(5);
Then you'll be up and running. You can start your application again, and you can take another backup. Finally you may want to issue this command.
UPDATE mytable SET mycolumn = TRIM(mycolumn)
to deal with potential trailing spaces in your old column values.

mysql error on OrthoMCL

While working with OrthoMCL I get to a part in which I have to upload my data in MySQL and then the program should make pairs of my data which are basically protein sequences.
While running the command orthomclPairs I get the following error
DBD::mysql::st execute failed: Table 'BestQueryTaxonScore' already exists at /home/sebastian/Downloads/OrthoMCL_v_2.0/orthomclSoftware-v2.0.9/bin/orthomclPairs line 709, <F> line 14.
To me it seems my database is full of information from a previous analysis and some tables may have the same names so a good solution would be reset the database .
AM I right? How can I solve this issue?
I appreciate your help and I' m sorry if something I say does not make sense but I am very new to "computers".
So the answer to my question is this:
Drop the database everytime you've ran the program (i.e. everytime you have uploaded the parsed BLAST search).
The database can be droped as follows:
mysql -u user -p DATABASE NAME (login with privileges)
Then this
drop database YOUR_DATABASE (this will delete all the tables for this database)
Then this
create database YOUR_DATABASE; (adds back the database namespace)
then just installschema outside MySQL
I hope it' s helpful for other working with MyOrthomcl.
Without any familiarity with this OrthoMCL software, it's perfectly obvious from the error message that the script attempted to create a table that was already present.
If you're setting up to work on a new problem, perhaps there's a way to create a new database. In MySQL parlance, a new database will let you create tables with the same name in it.
Or, as you say, you might "reset" your existing database. But that's OrthoMCL parlance, not MySQL parlance.

Corrupted MySQL DB - Data not stored or erased on inserts on one table but when changing that table name the code works

I have a corrupted DB and i'm not sure what to do with it. What happen is i have Flex app with a PHP backend where in some parts i need to do multiple inserts in a table, everything seems to work fine, no errors. After running my code i make a select on that table and there's nothing showing up in the table.
I checked everything, i mean everything:
I checked login info.
I trace the code up to the end, the query even shows up in workbench.
I tried inserting with a direct string i made up myself and tested before in workbench, nada .
If i insert data directly from workbench it works.
After data has been inserted from workbench, i run it thru php and instead of updating the db it erase what i have previously inserted in workbench.
So i'm thinking something could be wrong with my computer setup ..., so i set up an environment on another machine. No success here either same thing happens.
I then proceed to boot up an AWS machine with a different environment, same thing here too.
I tried to drop the table and recreate it manually, no success either.
Last thing i did was create the table with a different name, bang that works from everywhere.
Does anybody have clue what could happen here and some way to solve this has i don't want to change the table name, and by the way that table is not a new table and it was working fine before.
If you could give the table name that would be great. Perhaps it's a conflicting keyword you used in the table name that's causing your troubles?

MySQL archive data...what to do when it's too big

I use an INSERT INTO & DELETE FROM combination in a PHP script to take data out of an operational MySQL table and put into into an archive table.
The archive table has gotten too big. Even though no day-to-day operations are performed on it, mysqldump chokes when we back up (error 2013):
Error 2013: Lost connection to MySQL server during query when dumping table 'some_table' at row: 1915554
What can I do? Should my PHP script move it to another DB (how?)? Is it okay to keep the large table in the operational db?--in that case, how do I get around the mysqldump issue?
Thanks!
Are you by chance dumping using memory buffering and running out of swap and physical RAM? If so, you can try dumping row by row instead.
Try adding --quick to your mysqldump statement.
According to the documentation, you should combine --single-transaction with --quick.
Source: http://dev.mysql.com/doc/refman/5.5/en/mysqldump.html
Look for #Will's answer for a 2013 Error code due to a table being oversized.
That, however, turned out not to be my problem. When I ran a SELECT where giving it a WHERE id>500000 AND id<1000000 (example), I quickly found out that a section of my data had been corrupted.
Because of this I couldn't copy the table content over, I couldn't back up the table (or the database) using mysqldump, I could even say DELETE FROM to get rid of the corrupted rows.
Instead I used CREATE TABLE some_tbl_name SELECT * FROM corrupted_table WHERE id>500000 AND id<1000000 and then once I had the data that wasn't corrupt saved into another table, I was able to drop the corrupted table and create a new one.
I'm not accepting my own answer because Will's is correct, but if anyone runs into the same issue, I've posted it here.
mysqldump --opt --max_allowed_packet=128M base_de_datos > bd.sql
it works for me
You can try --var_max_allowed_packet=??? and --var_net_buffer_length=???
You can also try disabling extended inserts: --skip-extended-insert
But this is assuming your diagnosis of too large of a table is correct.
Just how big is this table?
As for the second issue, try logging directly into the MySQL server and running mysqldump from there, preferably writing the dump to a local filesystem, but a network connection moving plain data is far more reliable than any SQL connection.

Tables persist after manually deleting database?

After I navigate to my database in C:\ProgramData\MySQL\MySQL Server 5.5\data and delete the folder the tables are still saved somehow. When I try to run my PHP script again I get this error: "Error creating users table: Table 'databaseName.tableName' already exists."
The line of code that triggers that error is this:
mysql_query($createTableQuery) or die('Error creating users table: ' . mysql_error());
In order to fix this problem I have to rename the tables and re-run the script. It is becoming quite cumbersome having to find new table names every time I delete my database while testing my code.
Is anyone aware of a command to delete the tables as well? Or perhaps where the tables are stored on my computer so that I could manually delete them? I'd prefer to stay away from commands and rather know exactly where these tables were stored so that I could find them and delete them.
Are you aware of (?):
DROP TABLE [name];
You should be using drop database
not deleting the files. There may be metadata stored elsewhere.
I'd prefer to stay away from commands
and rather know exactly where these
tables were stored so that I could
find them and delete them.
This is naive way of thinking. Use the public interface (SQL) not the filesystem. What will you do if the storage mechnism changes? There are many storage engines in mysql and they all don't work the same way.

Categories