Common MySQL Connection Errors

Many websites use MySQL databases to store information and settings. However, there are some reasons why the connection to the database may fail. This article describes some commonly seen error messages when connecting to a database, as well as some general tips to keep in mind when setting up a database connection.

Common Error Messages

Using MySQL is great, but the error message returned if there is an issue logging in to your database can be quite confusing. Here are some commonly seen error messages and reasons which cause them.

Unable to connect to database / Error connecting to database

This error message means that your software is unable to setup a working database connection for some reason. What reason is that? That’s information that your software is hiding to protect sensitive information.

If you’re using off the shelf software, you should check if your software has some kind of error log or debug functionality that can show the real error message.

With WordPress, this is done with the WP_DEBUG option. You can learn more about that option in the official WordPress support article: https://wordpress.org/support/article/debugging-in-wordpress/

If you wrote the software yourself, you should use something like mysqli_error or mysqli_connect_error (if you’re using MySQLi) or mysql_error (if you’re using the outdated MySQL library). Using the PDO library should throw a PDOException which you can print for more information.

It’s also a good idea to enable Display Errors in your control panel, which will ensure that any errors from PHP are shown. You can find this option under Alter PHP Config in your control panel.

No such file or directory

The message No such file or directory is shown when you’re using localhost as your database hostname. Using localhost means your script will look for the database on the same server as your website, which does not work on InfinityFree.

The database hostname should look like sql123.epizy.com, but the exact value depends on your account. You can find your database hostname in your control panel under MySQL Databases.

Access denied for user

You can see an error message which looks like Access denied for user 'epiz_12345678'@'192.168.0.*' (using password: YES). This message means that the user was able to connect, but does not have access to the provided database name.

This could mean one of two things.

This generally means that the database name is not correct. If you entered the database name my_database when creating the database, the full database name looks like epiz_12345678_my_database. The easiest way to make sure you have the right database name is to go to the MySQL Databases section in your control panel. If you haven’t created your database yet, you can also do it through this menu.

It could also mean that your database password is incorrect. The database password is the same as your hosting account password (which is different from your client area password!). You can find your hosting account password by logging in to your client area, click Manage next the account, scroll down to MySQL Details and click Show next to the Password field.

General Tips

Here is a short checklist to go through which should help solve most common issues.

Make sure you are using your hosting account password

The most common issue is that people are not using the right database password. You should use the hosting account password in your script configuration.

Important: the hosting account password is not your client area password! The hosting account password is randomly generated when you create an account, and you can find or change it in your client area (click the account in the accounts list).

Make sure you are using the right database hostname (not localhost)

Most hosting providers use localhost for the database hostname. This does not work for InfinityFree. The database hostname should look like sql123.epizy.com. You can find your database hostname in your control panel in the MySQL Databases section.

Make sure you are using the right database name and username

Your database name and database username can be found in the MySQL Databases in the Control Panel of your hosting account. The database username typically looks like epiz_12345678 and the database name looks like epiz_12345678_mydb.

Make sure you are connecting from within hosting account

InfinityFree databases are only accessible from within your InfinityFree hosting acounts. Our database servers are not accessible from other locations, like developer tools on your own computer, websites on other hosting providers, game software, mobile apps and so on. Remote database access is only available with premium hosting.

I’m sure I’m using the right database credentials

If you’re absolutely sure you are using the right database password, database hostname, database name and database username, but you are still unable to connect to your database, you can get help by opening a new forum discussion. When doing so, please don’t forget to include the full error message returned by the database connection code!

2 Likes
Error establishing a database connection
PHP sql connect not working
Can not connect to my database
'Warning: mysqli_real_connect(): (HY000/1045): Access denied for user' Error
INSERT not working
How to connect DB with Bedrock WP?
Access denied for user 'epiz_31263592'@'192.168.0.64' (using password: YES)
My website is returning: Error 520 Web server is returning an unknown error
Http error 500
Can't migrate Laravel database
Database connection
Erro SQLSTATE[HY000] [2002] Connection refused
Error mysql
Cannot connect to MySql DB from PHP code?
My DB is allright? DB connection is good?
Can't access to my website
Too Much Slow Speed
Host does not exist when calling it using php
Database connection error
Php code is not being executed
Unable to connect to database
Error establishing connection with database
Can't connect to DB please reset my permissions:
My website not showing
Create new dbuser
Database error
My site doesn't work well
GDPS Custom Server Fix
MySQL and PHP connection Fatal error
Error establishing a database connection
The MySQL Connection could not be established
SQLSTATE[HY000] [2002] No such file or directory
WordPress WooCommerce plugin not loading/error
Unable to Connect to MySQL Host (sql305.infinityfree.com or sql305.epizy.com)
Database Connection Failed
Error establishing a database connection
Index.php not found
SQL connection timeout
Error with Database
Media Wiki Extension:GlobalBlocking Error
SQLSTATE[HY000] [1045] Access denied for user 'if0_37419617'@'192.168.0.4' (using password: YES)
Mysql error access denied
Can i send POST data to my website from ROBLOX?
Please help, php language 500 error
Php script installation
Problem with PHP!
Why is this happenning?
Database MYSQL can not acces
Error establishing a database connection
Sql207.epizy.com doesn't load
How to solve Failed: No such file or directory problem
Error establishing a database connection
My MysQL Database Removed
Not Connected Problem
Error connecting to database
Can I Open DB Using MySQL Workbench?
Sqlstate[hy000] [1045
Mysql Databasses
Sqlstate[hy000] [1045
Troubleshooting error returning json when acessing db table
Database Corrupted
Cannot connect to mysql database
"Random" Error establishing a database connection error on TMAC PowerStore
Error establishing a database connection
Error creating a MYSQL function
Having a data base issue
How to connect PHP with MySQL
Website is not loading
The optional module, imagick, is not installed, or has been disabled
I've uploaded admin folder but when I check in url it's showing no such file or directory
Database link failed
My PHP will not connect with my SQL
SQLSTATE[HY000] [2002] No such file or directory
Sql down
Error establishing a database connection
Database not working
Problem of connection to the database with php code
My database is not connecting
Site Keeps Getting Redirect to ww01.site.com
Error establishing a database connection
Why i cant reached my website?
Impossible connection on mysql
Error establishing a database connection
Warning: mysqli::__construct(): (HY000/2002): No such file or directory in /home/vol1000_5/epizy.com
Access Denied when accessing database
SQL Connection Error PDO PHP
Pages with mysql won't load
PHPAdmin Page Not Found
Multiple sites having database connection errors
Unable to connect db
A problem during making back up
Access denied to Mysql database
Mysql
How to output latvian symbols?
My website doesnt work as it should idk
Website suspension
Error establishing a database connection wp admin
Database servers are Down!
Error-Report: Access denied for user 'epiz_xxx'@'192.168.0.%' to database 'epiz_xxx_xxx'
Mediawiki error
Unable to connect to MySQL with PHP PDO
Error establishing a database connection
Login to wordpress?
Can't connect to server on 'sql212.epizy.com' (10060)uery
Probleme daccess base de donnee Mysql
Randomly database unable to connect
Connection failed: No such file or directory
Problem installing PHP script
How to solve an error problem in establishing a connection to the database Although all the codes ar
Database connection error
"Connection timed out" Error when I try to connec o mysql db
Database access denied
Database connection error
Connection failed: Access denied for user 'epiz_34169135'@'192.168.0.36' (using password: YES)
Can't submit data to database with php
Phpmyadmin-acess-denied
Access denied for user
Website not working
Slow Service
WooCommerce Payments/Database problem
Access denied for user 'if0_USER'@'IP'
Database error
I can not connect to mysql
I can not connect to mysql
Opencart
error database
I Want Help To My Domain
Phpmyadmin error 500
Https://okhalhavoinvestiment.great-site.net/
Database Connection
How to make WordPress use old database?
Which file is need to upload on file manager for web hosting
This Weird Error With MySQL and PHP
403 error on site
HTTP Error 500
Error 1044 - Access Denied al conectar MySQL
Problemas para conectar mi base de datos con los archivos
Error 500 connection refused
Error Establishing a Database Connection for doai.ct.ws
Error Establishing a Database Connection for doai.ct.ws
Cannot Select Database `if0_37984521_doai` - User `if0_37984521` (Account if0_37984521)
Script install databases worng user and password
I have successfully migrated my WordPress site, but nothing is displayed
I cannot connect to MySQL server, but I still can open it via PHP Admin
Database Connection failed
Error establishing a database connection
Access Denied Error for MySQL Database
Access Denied Error for MySQL Database
Cannot connect to MySQL database - access denied error
I need to migrate and I can't set up the database
Mysql 1104
Error 1045: MySQL sees connection from local IP 192.168.0.42
Falha de ConexĂŁo MySQL (cĂłdigo de erro 2002) - DomĂ­nio: mygestao.wuaze.com
Webapplication does not start
DataBase user don't have privilege
React+php hosting
Error establishing a database connection
I don't have access to my phpBB forum
Infinity free wordpress websites are not working database is down
Access denied for user in MySQL database
Boa noite. meu site carrega o index mas nao conecta com o banco . http://portaldoitalo.rf.gd/
My domain doesn't work
403 Forbidden error
Error has been fixed
Fatal error: Uncaught mysqli_sql_exception
Error with a project
My SQL website isn't showing up
XMLHttpRequest blocked by CORS
Form's script can't conect to database
Query error: access denied
Access denied for user
Title: MySQL Access Denied to database if0_40779674_punjabnaukri on account if0_40779674
Connection failed: Access denied for user 'epiz_33659823'@'192.168.0.36'
Can't see the login form of website with mysql
Error: (1045) Access denied for user 'ifo_34473355'@'192.168.0.48'
Database erro
Config server file when uploading to Infinity
Wordpress website migrate
Cloudflare https://errors.infinityfree.net/errors/404/
I have contracted the free plan. What PHP version is using?
Access Denied Database Problem
Failed to load resource: the server responded with a status of 500 (Internal Server Error)
SQLSTATE[HY000] [2002] No such file or directory
Error establishing a database connection
What happens to sql213.byetcluster.com
This websit isn’t working
Please help me, how to add user a mysql database?
Error establishing a database connection
Error establishing a database connection
Issue with Connecting Database to My PHP Application
Issue with Secure Connection on My Website
I can't link my database
No such file or directory