Questions tagged [mysql-error-1050]

MySQL Error 1050: Table 'database.tablename' already exists

You can get MySQL Error 1050 when you are trying to create a table that already exists:

mysql> SHOW TABLES;
+-----------------------+
| Tables_in_database    |
+-----------------------+
| MY_TABLE              |
+-----------------------+
mysql> CREATE TABLE MY_TABLE (ID INT);
ERROR 1050 (42S01): Table 'database.MY_TABLE' already exists

but also for a number of other reasons (filesystem corrupted, database that needs to be fixed, etc.)

13 questions
108
votes
9 answers

MySQL "CREATE TABLE IF NOT EXISTS" -> Error 1050

Using the command: CREATE TABLE IF NOT EXISTS `test`.`t1` ( `col` VARCHAR(16) NOT NULL ) ENGINE=MEMORY; Running this twice in the MySQL Query Browser results in: Table 't1' already exists Error 1050 I would have thought that creating the…
user199559
  • 1,095
  • 2
  • 7
  • 5
87
votes
28 answers

Mysql 1050 Error "Table already exists" when in fact, it does not

I'm adding this table: CREATE TABLE contenttype ( contenttypeid INT UNSIGNED NOT NULL AUTO_INCREMENT, class VARBINARY(50) NOT NULL, packageid INT UNSIGNED NOT NULL, canplace ENUM('0','1') NOT NULL DEFAULT '0', …
Citizen
  • 12,430
  • 26
  • 76
  • 117
23
votes
9 answers

Adding foreign key to existing table gives error 1050 table already exists

I've a table CustomizationSet with the columns: customization_set_guid (which is a non-nullable guid and also the primary key) creator_account_guid and a few others And a table with existing data Registration with the columns: registration_id (an…
avaleske
  • 1,793
  • 5
  • 16
  • 26
4
votes
1 answer

Can't delete a mySQL table. (Error 1050)

I have a pesky table that will not delete and it's holding up my dev environment refresh :( I know this table exists. Example... mysql> select * from uc_order_products_qty_vw limit 10; +-----+-------------+---------+---------+---------+---------+ |…
doublejosh
  • 5,548
  • 4
  • 39
  • 45
3
votes
1 answer

Error 1050 when trying to add foreign key constraing in MySQL

I have tried adding a column to my UserOrder table called discountcode. This is a nullable foreign key into alter table UserOrder add column discountCode varchar(100) null; alter table UserOrder add foreign key…
benstpierre
  • 32,833
  • 51
  • 177
  • 288
2
votes
1 answer

How to change id in existing MySQL tables with data to autoincrement from last highest id?

I have just managed to migrate a pretty big database from SQL Server to MySQL. I didn't set the primary keys to auto increment during the migration because the tables have relationships based on ids as primary keys which are foreign keys in another…
Moin Zaman
  • 25,281
  • 6
  • 70
  • 74
2
votes
2 answers

CREATE TABLE IF NOT EXISTS failing when the table exists

I have the following code: $db_host = 'localhost'; $db_port = '3306'; $db_username = 'root'; $db_password = 'root'; $db_primaryDatabase = 'dsl_ams'; // Connect to the database, using the predefined database variables in…
Samuel Stiles
  • 2,118
  • 5
  • 22
  • 27
1
vote
1 answer

Issues with ORDER BY caused by changing the DATE_FORMAT in the SELECT statement

I'm doing a Databases assignment for Uni and I'm stuck. I'm 99% of the way there. The brief is: Create a query to view the annual sales over the last 12 months of the business showing the total number of products sold and the total price sold every…
iGleeson
  • 13
  • 5
1
vote
2 answers

MySQL-Error: Table or view already exists

I try to create a table in MySQL but I get the following error: SQLSTATE[42S01]: Base table or view already exists: 1050 Table 'migrations' already exists (SQL: create table migrations (id int unsigned not null auto_increment primary key, migration…
Hashan
  • 164
  • 8
1
vote
1 answer

Mysql 1050 followed by 1051

Please help me figure this one out. I've already tried deleting and re-creating data files, flushing tables, restarting the database and entire server. InnoDB is in Force Recovery = 4 >mysql -u root Welcome to the MySQL monitor. Commands end with ;…
St.Woland
  • 5,357
  • 30
  • 30
0
votes
2 answers

How do you version and sync your MySQL data model?

What's the best way to save my MySQL data model and automatically apply changes to my development database server as they are made (or at least nightly)? For example, today I'm working on my project and create this table in my database, and save the…
Mike M. Lin
  • 9,992
  • 12
  • 53
  • 62
0
votes
1 answer

Workbench Mysql Import ERROR 1050 (42S01)

Using Xampp/MySQL. Exported win7 MySQL database. Import to another win10 machine with same Xampp/MySQL version. Made sure the "sc2" database did not exist in the Win10 setup (no directory). But during import, Workbench gave error of "22:53:38…
HDer
  • 385
  • 5
  • 17
0
votes
5 answers

Is .sql file different for MySQL and SQL?

I have a .sql file and I want to load it into MySQL database. I don't know from which database (MySQL or MS-SQL) it was created. Now, I am trying to import that file into MySQL database. It is showing errors while importing and executing that…
Amit
  • 33,847
  • 91
  • 226
  • 299