Sort by:

Category: MySQL Tricks

How to setup a MySql replication database for WordPress

WordPress use MySql database to store all the plugin options, theme options, your pages, your posts, users and comments, with more visitors your site need to be able to scale or in my case I had user spikes (increased traffic) that took out the connection to MySql, as memory on the server was used up. Scaling your site by replicating your MySql database is a good start. MySql replication is a process that allows you to easily maintain multiple copies of a MySQL data by having them copied automatically from a master to a slave database.

Merging two MySql tables

How to merge two MySql tables that have the same structure and were the primary keys of the two tables will clash.

One option is:

    INTO table_1
    SELECT *
    FROM table_2;

which allows those rows in table_1 to supersede those in table_2 that have a matching primary key, while still inserting rows with new primary keys.


     INTO table_1
     SELECT *
     FROM table_2;

will update those rows already in table_1 with the corresponding row from table_2, while inserting rows with new primary keys.