still error "multiple primary keys defined" when tables/databases are dropped - mysql

I want to put my live site (wordpress) on localhost, so I exported the database (turning on the options for dropping database and tables) with phpmyadmin. When importing on localhost with BigDump I get the error message that "Multiple primary keys are defined".
How can I solve this?
All the suggestions I have read so far say to drop the tables and/or database when exporting from live site. I did that but it makes no difference. What else can I do to succesfully import the DB on localhost?

Check your create table statements in exported file. May be somewhere in your create statemate two primary keys are defined.
A table can have only one primary key, which may consist of single or multiple fields. When multiple fields are used as a primary key, they are called a composite key.
If possible cereate database and tables manually and remove table creation statements from expoted file and you can source only data from the file.

Related

Dropping a table and foreign keys for a Microsoft Access DB using FireDAC (JET)

I need to (programmatically) drop a table from a Microsoft Access database (.mdb file in 2002-2003 format). When I drop the table, I need to drop all the foreign keys. The foreign keys were created with different names, so I need a way to iterate over them to drop them.
FireDAC has a TFDMetaInfoQuery component with a MetaInfoKind of mkForeignKeys. I can get that to execute, but it never returns any rows, either for the entire database or if I specify an .ObjectName. As a test, I switched to mkTables and I do get data returned.
I can query the relationships in Access by using the MSysRelationships table, but when I try to query that directly from FireDAC, I get an error message:
Could not read definitions; no read definitions permission for table or query 'MSYSRELATIONSHIPS'
Is there a way to:
Drop a table in Microsoft Access and get it to drop the foreign keys at the same time?
Iterate over the foreign keys that are pointed to a given table so that I can drop them myself?
Or, is there any other way of dropping this table that I am not considering? If need be, I can get a TADOConnection, but I didn't see any way that would help, either.

Why all the tables in phpmyadmin cpanel is missing create edit delete and unique id?

I have hosted my Laravel project on Shared hosting.
Everything works fine on local but my main problem is in Phpmyadmin when i imported my sql file into it.
In my local i every table has primary key, auto increment and unique id for all the rows in every table. But when i imported sql into cpanel phpmyadmin all the table doesn't have unique id and no option for create edit update and delete.
The two problems are related, something has gone wroing in the import process and you don't have a proper primary key defined therefore phpmyadmin won't let you do updates or delete.
How did you export and import the data, please explain step by step so we can help you.
Add id as primary key and auto increment.Then it will show all options.
Note: Its not php issue.

MySQL Export "Dumb" Version of database (No keys, no auto-increment, just tables of data)

I'm trying to export a fairly complex mySQL database from the working local server to upload on to an online server for collaborators to READ ONLY the data within.
The database has a number of Foreign keys, and every table has a primary key. However, since NO DATA WILL BE ADDED to this dumb "shadow" copy, these are irrelevant, and frankly creating a headache trying to get them to import successfully.
So... IS there a way to export a MySQL databases' structure (and possibly data) withOUT any keys, keeping the autoincrement column, but just treating it like any other INT column, and removing the foreign key constraints?
You can export a MySQL database without AUTO_INCREMENT options this way:
mysqldump --compatible no_field_options ...
I don't know of any way to omit the foreign key constraints. But if you use mysqldump, the export does SET FOREIGN_KEY_CHECKS=0; before creating any tables. This allows tables to be created out of order.
Re your comment:
If you really can't allow foreign key declarations in your table definitions, you'll have to edit them out of the MySQL export file. You can do this manually with any text editor, or else come up with a filter using sed or perl or a variety of other tools.
There's an example of a sed command in one of the answers to How do I dump MySQL file without Foreign Keys via command line?
It might be easier to drop the constraints in your tables before you export the database.

Export table data without Primary Key

I want to export data from a sql table, but I dont want the primary key to be exported.
The reason is that I have data on my localhost that needs to be inserted in a remote database (remote and local db have the same structure). But on the remote db, the table already has data, and they will be primary key conflicts if I try to add the data from my localhost.
This question has somehow been treated here before: table-without-dumping-the-primary-key.
I used this method in the past, but it's annoying to have to create a new table to make the transfer...
It surprises me that I can't export data from a table while omitting a column, in this case, the primary key column.
Been looking the mysql documentation but it wasn't helpful...
Any idea?
Can you create a VIEW without the primary key, and then export VIEW DATA?

Link in foreign keys in phpmyadmin

I have foreign keys set in a mysql db. I have backed up my db from one server to a new one. Both the new and the old server use phpmyadmin. On the old server, y used to have a link in the view of a table from the foreign key to the respective register in the other table. An html link that leads me to the register in the other table. But it doesn't appear on the new server.
Any ideas?
You'll need to set up the pmadb meta-tables: http://www.phpmyadmin.net/documentation/#linked-tables
After that, you should get the links between foreign keys when browsing. You can also use $cfg['Servers'][$i]['relation'] to set up the relations you want hyperlinked by hand: http://www.phpmyadmin.net/documentation/#cfg_Servers_relation
I don't really get what you mean. In order to import data to a new phpMyAdmin, you need to export the data to sql and import the exported sql file. All the foreign key will still remain the same as what you have imported is in the form of sql.