Creating Users: an illustration of the differences between PostgreSQL and MySQL
10:29 Thursday, 19 November 2009
Like many starting out in websites and databases my first experience was with MySQL. I had no choice since the hosting service I used only offered MySQL. This is still the case for a lot of hosting - you get the standard LAMP stack and nothing more. I had read on the web that everyone is using MySQL, so how bad could it be? I was forgetting the maxim that quality and popularity are inversely proportional. BTW: it’s not really popularity in this case - it’s the most users - think Windoze.
Anyhoo, I struggled through the nightmare that is the MySQL documentation and the quagmire that is PHP for a while, all the time thinking there must be some better. For me the something better was Django, Python and PostgreSQL. I’d known about Python for years but had never tried it. The white space significance had put me off. But then someone pointed out that you indent your code anyway, a light went on and I gave it a go. What a breath of fresh air. Now I write everything I can in Python.
On to databases. The excellent Django documentation recommends PostgreSQL. I had never tried it but by this point in time I had my own web servers so there was no reason not to give it a go. Again a light went on and I was like “Oh, so database documentation does not have to be poorly written opaque crap”. I could actually read and understand and do stuff with the PostgreSQL documentation. Also the database is, technically, excellent and logically thought out. Let me illustrate this point with the example of creating users in the database. Not something that we have do to many time a day but illustrative nonetheless.
In PostgreSQL, if you want to create a user, there is a command called… createuser
In MySQL, the MySQL documentation recommends opening a mysql shell and typing the SQL like this:
mysql> CREATE USER ‘monty’@’localhost’ IDENTIFIED BY ‘some_pass’; mysql> GRANT ALL PRIVILEGES ON . TO ‘monty’@’localhost’ WITH GRANT OPTION;
WTF? I know there’s a GUI MySQL admin tool but what good is that when you’re operating on the command line? And I know there’s phpmyadmin but why would I install PHP and configure the tool just to do a few commands which should be simple.
So there you have it, you can choose well documented simplicity or poorly documented complication. It’s not a difficult choice but it’s one few get a chance to make. Do yourself a favour say no to the same old bland LAMP stack and give Django and PostgreSQL a try. You’ll like it. Honest.