MySQL and Postgres quick start…

Every 6-12 months I need to setup a new mysql and/or postgres database – and by then have forgotten how to do it (again). So hopefully by writing it here, I will remember or at least know where to go in future.

Assumed this is on Ubuntu… and that mysql/postgres installed already.


Create the database

sudo mysqladmin create [dbname]

Create a user for that database, using the mysql tool (user has no password, can only logon from localhost)

sudo mysql

mysql> GRANT ALL PRIVILEGES ON [dbname].*
       to '[new user]'@'localhost';


Create the db

createdb [dbname]
Create the user

sudo -u postgres createuser –superuser [new user]


As usual, work in progress, to be updated/added to as I learn a little/need more.