Migrate WordPress From Localhost To Live Server

You have a working wordpress website on your localhost server and when you need to migrate or copy the same wordpress website to your live server, what should you do ?

To install a fresh copy of wordpress and put all the data again and again is very frustrating.

I think almost all the wordpress developers face this problem. I have a solution to this problem.

There is a very simple way to get rid of this problem.

You just need to download the SQL file from your database and make a copy of your wordpress website folder.

Now open the wp-config.php which is present at the root directory and write the database details you have for your live server.

Now open the SQL file in the editor (I prefer Adobe Dreamweaver), and find http://localhost/yourfoldername/ and replace this with http://www.mywebsite.com/.

You are all done. Just upload the folder through any FTP client and upload the database and enjoy your website fully functional like your local version.

Can we have multiple primary keys in a single table?

No we Cannot.
For example,

CREATE TABLE IF NOT EXISTS `usr` (
`id` int(11) NOT NULL,
`survey_id` int(11) NOT NULL,
`number` int(11) NOT NULL,
`count` int(11) NOT NULL,
`date` date NOT NULL,
PRIMARY KEY (`id`,`survey_id`,`number`,`count`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

Basically, this appears to be creating four primary key on one table.

We could create a number of unique keys in one table, but only one primary key.

Then how is it that your system is allowing the creation of multiple primary keys?

Think of it like it suggest, a ‘KEY’. So the key would be all of the columns specified. In your case you can have multiple rows with the same ‘ID’ and multiple rows with the same ‘survey_id’ but there shall never be two rows that have the same ‘ID’ AND ‘survey_id’.

So in this case it is not saying that the column ‘ID’ must be unique nor is it saying that ‘survey_id’ must be unique, but only the combination.

Like if you write an query

INSERT INTO `usr` (`id`, `survey_id`, `number`, `count`, `date`) VALUES (1, 1, 123456, 50, ‘2013-04-01’);

And after this you again run this query then you are getting an error “#1062 – Duplicate entry ‘1-1-123456-50’ for key ‘PRIMARY'”

What is the differences between InnoDB and MyISAM?

InnoDB

MyISAM

InnoDB implements row-level locking. MyISAM implements table-level locking.
Automatic Crash Recovery. No Crash Recovery
InnoDB doesn’t have FULLTEXT search indexes. MyISAM have FULLTEXT search indexes.
InnoDB also implements transactions, foreign keys and relationship constraints. MyISAM does not support transactions, foreign keys and relationship constraints.
InnoDB stores both data and indexes in one file. MyISAM stores indexes in one file and data in another.
InnoDB uses a buffer pool to cache both data and indexes. MyISAM uses key buffers for caching indexes and leaves the data caching management to the operating system.

In InnoDB the COUNT(*)s (when WHERE, GROUP BY, or JOIN is not used) execute slower than in MyISAM because the row count is not stored internally.

Overall I would recommend InnoDB for most purposes and MyISAM for specialized uses only. InnoDB is now the default engine in new MySQL versions.