server mysql localhost not worker, only 127.0.0.1

wordpane

New member
Joined
Jan 9, 2025
Messages
7
Guys, see if you can guide me, my server is configured with MariaDB, my main admin user account with a WordPress installation works very well, but if I create a new user and install WordPress, a connection error occurs with the database using localhost, so if I change it to 127.0.0.1 it works normally.

My /etc/host file is resolving to:

127.0.0.1 localhost localhost.localdomain
::1 localhost localhost.localdomain

I also have an entry with the server's IP resolving to the hostname.

I've already searched here on the forum for all the posts and so far I haven't been able to find anything that will make my installations work with localhost.
 
I don't now if it matters, but it looks you've got it the other way around. Normally it's hostname and then hostaliase.

Maybe try like this and reboot server:
Code:
127.0.0.1 localhost.localdomain localhost
::1     localhost ip6-localhost ip6-loopback

Not sure if it will make any difference, but one never knows.

You also have this in your /etc/my.cnf file?
bind-address=127.0.0.1

Check this thread (click) too.
 
Back
Top