Setting up MariaDB and WordPress

I'm having issues getting a database set up to work with WordPress using MariaDB. I followed the steps here and here (or at least I thought I did) but when I go to install WordPress it says it can't connect to the database.

The mysql service is running and the credentials are in the WordPress configuration file.

I also tried logging in to the database as the user I set up in the command-line but get an error about access denied and the hostname it spits out is localhost. When I set up the user, I passed it my new hostname (the new hostname is mapped to localhost in the hosts file) and verified that the new hostname is what's stored in the user table. Next, I tried overriding the host to the new host so that it matched the one in the table and get a new error: ERROR 2002 (HY000): Can't connect to MySQL server on 'hostname' (115)

I also tried logging in to the database using the new user and a password, which also failed. I'm sure I'm missing something basic here and any help would be greatly appreciated.

4 Replies

This is actually a pretty common MySQL/MariaDB error. I certainly understand your confusion because that error text is not very helpful. Rather than what the error would seem to indicate, this is unlikely to be related to the hostname on your Linode. Rather it has to do with the socket that MySQL is listening on.

What I would recommend is taking a look through the following configuration file:


Essentially you are trying to see if the line defining the socket file correctly references /tmp/mysql.sock which is the default socket for MySQL.

Another possibility is that your firewall is blocking the MySQL port. By default this is 3306. You might find out guide to iptables helpful in reviewing your firewall rules.

Finally, if you need a bit more information you can check out this documentation from MySQL and MariaDB.

Thank you for the assistance.

I changed the socket to /tmp/mysql.cnf but that gives ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2).

My database isn't being accessed remotely, do I still need to make the firewall changes?

Also, if it means anything, I also tried logging in to the database using sudo mysql -u <user> -p which also failed with access denied.

I just created a new user forgoing the step of entering a hostname this time at the mysql prompt and that new user worked. However, the hostname assigned to it is now localhost instead of my hostname. This leads me to believe that the hostname mismatch was the issue before. But the hostname isn't localhost. I could use it as it is now but, ideally, everything would match up.

Will having the hostname assigned to the database user being different from the actual hostname cause issues down the road and is there a good way of making everything consistent while allowing it to still work?

Looking closer, the hostname is actually '%' in the database table. Will this cause any issues or is '%' just a generic placeholder?


Please enter an answer

You can mention users to notify them: @username

You can use Markdown to format your question. For more examples see the Markdown Cheatsheet.

> I’m a blockquote.

I’m a blockquote.

[I'm a link] (

I'm a link

**I am bold** I am bold

*I am italicized* I am italicized

Community Code of Conduct