Categories
Databases How-To MySQL WebApps wordpress

How To Back Up WordPress with mysqldump

Here’s a quick how to:

1. Tar up the directory:

tar cvf WordPress.tar wordpress/.
bzip2 WordPress.tar

2. Dump the database.

mysqldump --user user_name --password --host example.com --extended-insert=FALSE database_name > database_name.sql

I personally use extended-insert set to false because I often have to read the SQL.

Here is how to restore from backup:


tar zxvf WordPress.tar.bz
mysql --user user_name -p -hexample.com database_name < database_name.sql

Be sure to replace user_name, example.com and database_name with the appropriate values for your system.

I hope this helps.

Categories
Databases MySQL TechBiz

Oracle Breaks MySql.com’s Search

If you go to the MySQL web site, and do a search on data type integer, you’ll notice something strange. The first result is a MySQL newsletter from May 2010.

It wasn’t always like this. A few years ago I blogged about how Sun broke MySQL. Sun went on to claim that MySQL working out of the box was something that was broken with MySQL, even though lots of sysadmins every where relied on this to get servers up and running quickly.

If you compare the search with what they have on Google, you’ll see that the first result and the many results below are *all* relevant.

Why do large organizations break what works?

Categories
Databases MySQL scalability hacking WebApps

Notes on adding more MySQL databases

Just notes for myself on adding more MySQL databases without shutting down the master database.

on existing slave:

/etc/init.d/mysqld stop

copy data dir from /var/lib/mysql and data from /var/run/mysqld to new slave database:

cd /var/lib
tar cvf Mysql_slave.tar mysql/*
scp Mysql_slave.tar root@new-db.com:/var/lib/.
cd /var/run
tar cvf Mysqld_slave.tar mysqld/*
scp Mysqld_slave.tar mysqld/*
scp Mysqld_slave.tar root@new-db.com:/var/run/.

copy /etc/my.cnf from old slave to new slave
add entry for new server-id

start existing slave:

cd /var/lib
tar xvf Mysql_slave.tar
cd /var/run
tar xvf Mysqld_slave.tar
/etc/init.d/mysqld start

start new slave:

/etc/init.d/mysqld start
mysql
start slave;

on masterdb:
e.g.:

grant replication slave on *.* to ‘repl’@’192.168.107.33’ identified by ‘password’;

test on master:
create database repl;

check on slave:
show databases; /* should show new database */

test on master:
drop database repl;

check on slave:
show databases; /* new database should be dropped */

Now it’s time to turn this into an automated shell script with Expect in there.