Warning: mysqli_connect(): (28000/1045): Access denied

Status
Not open for further replies.

jerome1g

Member
Messages
113
Reaction score
1
Points
18
When I try to connect to my database and user on x10 I get the following message:

Warning: mysqli_connect(): (28000/1045): Access denied for user '221cf1'@'localhost' (using password: YES) in/home/jerome1g/public_html/dbconfig.php on line 4

Connect string looks like this:

$conn = mysqli_connect('localhost',
'221cf1',
'dbusername,
'dbname');

Thank You
 

essellar

Community Advocate
Community Support
Messages
3,295
Reaction score
227
Points
63
That can't be your db user name. Your db user name will be prefixed with your cPanel user name and an underscore (ie yourname_dbusername).
 

jerome1g

Member
Messages
113
Reaction score
1
Points
18
Connect string now looks like this:
$conn = mysqli_connect('localhost',
'yourname_dbusername',
'dbpassword',
'dbname')

I get this new error message:
Warning: mysqli_connect(): (42000/1044): Access denied for user 'jerome1g_221cf1'@'localhost' to database 'career1transit' in/home/jerome1g/public_html/dbconfig.phpon line4
 

bdistler

Well-Known Member
Prime Account
Messages
3,534
Reaction score
196
Points
63
I get this new error message
the following settings should be used:
Host/Server Name - [ localhost ]

Port - [ 3306 ] (not necessary)

Username --> Your cPanel username followed by an underscore and the MySQL username you configured in cPanel

Password --> The password that you used when creating the MySQL user

Database --> Your cPanel username followed by an underscore and the name of the database that you created in cPanel
click on above

Remember: Free hosting accounts do not have remote MySQL access.
 

jerome1g

Member
Messages
113
Reaction score
1
Points
18
Connect string now looks like this:
$conn = mysqli_connect('localhost',
'yourname_dbusername',
'dbpassword',
'yourname_dbname')

I believe dbusername, dbpassword and dbname to be correct.

Here is the expanded error message I get:
Warning: mysqli_connect(): (42000/1044): Access denied for user 'jerome1g_221cf1'@'localhost' to database 'jerome1g_career1transit' in/home/jerome1g/public_html/dbconfig.phpon line4
Error: Unable to connect to MySQL. Debugging errno: 1044 Debugging error: Access denied for user 'jerome1g_221cf1'@'localhost' to database 'jerome1g_career1transit'
 

essellar

Community Advocate
Community Support
Messages
3,295
Reaction score
227
Points
63
Let's take this right back to basics. Did you create the database and the user using the cPanel Database Wizard? If you didn't, you don't own it.
 

jerome1g

Member
Messages
113
Reaction score
1
Points
18
Ok here is the latest I have. I have created a dummy dbuser for testing my connecting problem.

index.html

<!DOCTYPE html>
<html>

<body>
<p>
<a href="dbconfig.php">config file</a>
</p>

</body>
</html>

dbconfig.php
<?php
// connects to the mysql db or outputs an error

$conn = mysqli_connect('localhost',
'jerome1g_jerome',
'please',
'jerome1g_career1transit');

if (!$conn) {
echo "Error: Unable to connect to MySQL." . PHP_EOL;
echo "Debugging errno: " . mysqli_connect_errno(). PHP_EOL;
echo "Debugging error: " . mysqli_connect_error(). PHP_EOL;
exit;
}

echo "Success: A proper connection to MySQL was made! The my_db database is great." . PHP_EOL;
echo "Host information: " . mysqli_get_host_info($conn) . PHP_EOL;

mysqli_close($conn);
?>

Error Message:
Warning: mysqli_connect(): (42000/1044): Access denied for user 'jerome1g_jerome'@'localhost' to database 'jerome1g_career1transit' in/home/jerome1g/public_html/dbconfig.php on line 4

Error: Unable to connect to MySQL. Debugging errno: 1044 Debugging error: Access denied for user 'jerome1g_jerome'@'localhost' to database 'jerome1g_career1transit
 

jerome1g

Member
Messages
113
Reaction score
1
Points
18
When I created the database and dbuser I used "mysql database" Not the "mysql database wizard"
 

Livewire

Abuse Compliance Officer
Staff member
Messages
18,169
Reaction score
216
Points
63
I'm resolving this now; generally speaking, using the Wizard ensures you don't miss one of the more critical steps which is what's occurred here. You've created the database, and you did create the user, but the user does not actually have permissions to use the database. To do this normally, at the bottom of MySQL Databases there's an option to add a user to a database; doing this prompts for what permissions (I'm selecting all for it), then click Make Changes and that user will now have access to the database itself.

Can you check now and see if you are still seeing errors? At a minimum it shouldn't still be an access denied error, unless the password is wrong.
 

sperko

Member
Messages
258
Reaction score
4
Points
18
Like the others said, you can create database users on the same page you create the databases (if you're doing it via cPanel)

But most importantly: When you have created both the database and the user, add the user to the database
 

jerome1g

Member
Messages
113
Reaction score
1
Points
18
I'm resolving this now; generally speaking, using the Wizard ensures you don't miss one of the more critical steps which is what's occurred here. You've created the database, and you did create the user, but the user does not actually have permissions to use the database. To do this normally, at the bottom of MySQL Databases there's an option to add a user to a database; doing this prompts for what permissions (I'm selecting all for it), then click Make Changes and that user will now have access to the database itself.

Can you check now and see if you are still seeing errors? At a minimum it shouldn't still be an access denied error, unless the password is wrong.
 

Livewire

Abuse Compliance Officer
Staff member
Messages
18,169
Reaction score
216
Points
63
I only added the test user to the database; if you head to MySQL databases in cPanel you should be able to add the remaining user.
 
Status
Not open for further replies.
Top