Archive | mysql RSS feed for this section

10 May 2009 1 Comment

MySQL one database versus multiple databases

When designing an application – should you put each customer in a separate database or keep them all in one large central database?
When it came to start work on our new Clear Books accounting software last year, we had to make a fundamental database design choice between using a single database for all clients, or [...]

18 February 2009 3 Comments

PHP Web Application Security

Here are some tips to help you think more about security when developing a web app. 

Buy a good book on the subject, such as Securing PHP Web Applications and implement what you learn in your code.
Read through Web Application Security section on of the SANS Institute 2007 top 20 security risks. There are some useful tips on [...]

27 December 2008 5 Comments

A script to reset the MySQL root password

It’s a pain if you ever forget your MySQL root password. Fortunately it’s a fairly straightforward process to reset it, here’s how:

pkill -9 mysqld;
echo "UPDATE mysql.user SET Password=PASSWORD(‘MyNewPass’) WHERE User=’root’;
FLUSH PRIVILEGES;" > /tmp/reset-pass.sql
mysqld_safe –init-file=/tmp/reset-pass.sql &
sleep 10
pkill -9 mysqld;

A bash script to reset the mysql root password
To make the process easier, I’ve wrapped these commands up [...]

3 October 2008 0 Comments

Running mysqldump via ssh (direct host to host copy)

In order to run a mysqldump from one host to another over SSH you can run:

mysqldump dbname | ssh root@remotehost.com “mysql -D dbname”
This will pipe the output of mysqldump directly to the ssh connection which is running MySQL at the other end and receiving the mysqldump from standard input.

16 September 2008 2 Comments

Getting Apache, PHP and MySQL to work on Leopard

Enabling PHP
If you have upgraded from Tiger, you may need to complete this step to get Leopard’s version of Apache to work with UserDir (otherwise ignore this bit):

Copy your old userdir configurations from /etc/httpd/users/ to /etc/apache2/users/

PHP is normally disabled by the default Apache configuration, so you will need to load up a text editor and [...]

31 August 2008 6 Comments

Hosting multiple blogs on a single WordPress installation

As you can probably tell from this blog, WordPress is my favourite blogging tool. I’ve been using it for a couple of years now, and during that time I’ve been really impressed by it. So when I was recently asked if a single copy of WordPress could be used to power several blogs, I was [...]

29 May 2007 0 Comments

How to remove duplicate data with MySQL

Quite often I have found myself wanting to remove some duplicate data from a MySQL table without having to 1) write a script to de-dupe the table or 2) copy the data into a new table with unique indexes.
Well fortunately there is a quick (and dirty?) solution. Say for example you wanted to get rid [...]