Connecting to an online database

Solved
Tom -  
 Tom -
Hello,

I would like to access my database on my website for free. For that, I put it on db4free.net.
Then, I connect to it in PHP from a site I posted on biz.nf.
The command to connect is:
$bdd = new PDO('mysql:host=db4free.net; port=3306; dbname=name', '
user', 'password');
The user and password are the ones I use to connect to the database on www.db4free.net/phpMyAdmin.
On the site, the error "SQLSTATE[HY000] [2002] Connection refused" appears without me understanding why...
Could someone help me please?

2 answers

jordane45 Posted messages 30426 Registration date   Status Moderator Last intervention   4 830
 
Hello,
If you have entered the correct credentials and the correct database name, you can try replacing the host with its IP 85.10.205.173

--
Best regards,
Jordane
0
Tom
 
The name of the database is indeed the one displayed on phpmyadmin, the credentials are the ones for connecting to phpmyadmin, and I have exactly the same problem when replacing it with the IP.
Otherwise, could you please suggest another method to display my database, through other sites whose methods have been verified for example?
0
jordane45 Posted messages 30426 Registration date   Status Moderator Last intervention   4 830 > Tom
 
Your code seems correct
While looking online, some indicate that the port used by db4free might be 3307 instead of 3306..
You can give it a try.
0
Tom > jordane45 Posted messages 30426 Registration date   Status Moderator Last intervention  
 
Always the same problem when changing ports...
0
jordane45 Posted messages 30426 Registration date   Status Moderator Last intervention   4 830 > Tom
 
Try to connect to it using software like HeidiSQL
https://codes-sources.commentcamarche.net/faq/10778-heidisql-tester-ses-requetes-sql

Personally.. I just created a test database on their site.. and I can't even access it via phpMyAdmin...
0
Tom
 
Incredible... It suddenly started working without me changing anything...
0