MySQL is the preferred database for WordPress, however not everyone likes MySQL and there is no easy alternative to make WordPress use another database.
If you want to use PostgreSQL with WordPress there is a WordPress plugin that will allow you to do it without making any changes to the internal WordPress codebase.
PostgreSQL for WordPress (PG4WP) gives you the possibility to install and use WordPress with a PostgreSQL database as a backend. It works by replacing calls to MySQL specific functions with generic calls that maps them to another database functions.
When needed, the original SQL queries are rewritten on the fly so that MySQL specific queries work fine with the backend database.
Support for other database can also be added if the appropriate drivers are written for them.
We tested this out on a local installation and were able to use PostgreSQL with WordPress without any issues.
The only problem we see with the plugin is that you need to perform a fresh install for this to work, however it might work on older installations if you are able to import the MySQL database to PostgreSQL.