Hello Everyone

I am using this service 000webhosting.com to host my website. When I tried to connect to the database. I got this error

Could not connect to the database a7848759_lumos :SQLSTATE[28000] [1045] Access denied for user 'a7848759_fareedh'@'' (using password: NO)

This is my code below

`    $host = 'mysql1.000webhost.com';
`    $dbname = 'a7848759_lumos';
`    $username = 'a7848759_fareedh';
`    $password = '';
`try {
`   $conn = new PDO("mysql:host=$host;dbname=$dbname", $username, $password);
`    echo "ITS WORKING!!";
`} catch (PDOException $pe) {
`    die("Could not connect to the database $dbname :" . $pe->getMessage());



4 Years
Discussion Span
Last Post by Mohamed_26

Are you sure that the database URL for $host is really that one? I doubt it is correct. The $host value is NOT the domain name, but it must be the database URL. The easiest way is to use the IP address. You need to check with your host for the real URL for database.

PS: NEVER post real user name, password, or even database name! You should change the user name now even though you change the password from empty to something else!

Edited by Taywin


Yh, I will change it. I am just going to create a new user. The host name is mysql1.000webhost.com. MySQL host: mysql1.000webhost.com. That is the information displayed next to the username and password in my account


This error usually arises when you don't have permission to access the db. I'm assuming that you copied the local db into the hosted db with phpmyadmin or something similar.

I would be very surprised if you had a remote db that did not have a password. Remember that only the data is copied when you import data - not permissions. If you don't get any joy, use phpmyadmin to create a new user and then use those credentials in your php scripts.


No, I created the database on the 000webhosting.com. I also created the username and the password for the databases. I am using the phpMyAdmin provided by the hosting company. Hence, I had to create a new username and password on the PhpMyAdmin and using those credientials in my connect.php


Yes but you had this in your message:

(using password: NO)

So I'm assuming that you forgot to include it in $password

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.