I can't connect to MariaDB via php remotely, can connect via mysql

I'm going a bit crazy here with this today. I've migrated a database from another server to an Ubuntu linode installation. I've created a database user with privileges, and can connect to the database remotely with

mysql -u user -p -h server
Connection is fine and I can run commands, etc., but when I try to connect via php/mysql, I am getting a connection refused error.

Uncaught exception 'Exception' with message 'Error connecting to the database: Connection refused'

Show grants provides:

GRANT ALL PRIVILEGES ON database.* TO 'user'@'%'

ufw is currently disabled and nmap shows:

nmap -p 3306 server

Starting Nmap 7.60 ( https://nmap.org ) at 2019-01-21 19:13 AKST
Nmap scan report for li1779-40.members.linode.com (server)
Host is up (0.29s latency).

PORT STATE SERVICE
3306/tcp open mysql

Nmap done: 1 IP address (1 host up) scanned in 0.66 seconds

MySQL error log isn't showing anything, which makes me think it's firewall or routing related and if I change the database back to the original server, all works fine. Any ideas? Thanks

2 Replies

Did you configure MySQL to listen to remote connections? Also, I suggest using a SSH tunnel.

Yes, I have commented out the bind address. Any other ideas?

Reply

Please enter an answer
Tips:

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] (https://www.google.com)

I'm a link

**I am bold** I am bold

*I am italicized* I am italicized

Community Code of Conduct