• If you are still using CentOS 7.9, it's time to convert to Alma 8 with the free centos2alma tool by Plesk or Plesk Migrator. Please let us know your experiences or concerns in this thread:
    CentOS2Alma discussion

[solved] Wordpress connecting to external DB

Johan06

New Pleskian
Hello,

Since I transfered a wordpress to a new server with Plesk 12.5, my custom plugin who do a connection to an external DB to get infos doesn't work.

Where should I check to enable/disable a configuration in the plesk panel to solve this ?

Regards
 
What do you mean exactly "doesn't work"?
First of all make sure that this external database server is accessible from Plesk server - port and IP address is not firewalled, etc.
 
Well,

I got 3 servers with :
Website A on plesk 11.0.9
Website B on plesk 12.0.18
Website C on plesk 12.5

Website B and C do a connection to Website A Database to display some datas.
Website B works. (it display datas)
Website C display nothing (no datas and no errors displayed too...)

Before doing more deep test on the PHP code or other possiblity, I wanted to know if there was a configuration in plesk panel who can solve it.
Because Website C was on the same server than Website B and worked (displayed the data) so it's should be a problem with a security config i guess...

I use the wordpress function wpdb() to do the db connection.

The external database is accessible.
 
First of all, your mysql configuration needs to be changed that it doesn't listen only on localhost, so head to my.cnf and comment out bind_address/restart mysql. my.cnf location depends either if you're on centos /etc/my.cnf or debian/ubuntu /etc/mysql/my.cnf.

After that, it should work (in newer plesk versions you can define user connectivity and permissions per user, but since your website is connection to server A, I don't think you can define that-there). The simplest test would be to connect command line - shell and try to login with your user:

# mysql -u your_user_on_weba -p databasename -h IP_or_hostname_of_website A

you execute the above from web C

Good luck
 
Hi,

Thanks for your post.

I did what you said and I got this message :

ERROR 1130 (HY000): Host 'xx.xx.xx.xx' is not allowed to connect to this MariaDB server

I don't understand why it said that for a remote host


Problem solved. It's my bad.
Got same IP on this server... conflict..
I just deleted it.


Thanks all
 
Because your mysql user on web A exists only as user@localhost or [email protected] - there's no such user as user@webC - so yes, you need to create that user like this:

On webA server connect to mysql:
# mysql -uadmin -p`cat /etc/psa/.psa.shadow`
# CREATE USER 'your_user_on_weba'@'IP_or_hostname_of_website_C' IDENTIFIED BY 'password_of_your_user_on_weba';
# GRANT ALL PRIVILEGES ON databasename.* TO 'your_user_on_weba'@'IP_or_hostname_of_website_C';
# FLUSH PRIVILEGES;

Now you should be able to connect from server webC to webA. Good luck!
 
Back
Top