This either means that the username and password information in your wp-config.php file is incorrect or we can’t contact the database server at localhost. This could mean your host’s database server is down. code example

Example: error establishing a database connection

database name : your databse_name
username: root or your database username
password: ''
database host: 127.0.0.1:3306 or your MySQL port  /*add Mysql port */
table prfix: wp_

/*use this 127.0.0.1 port instead of localhost and
add mysql port 3306 after 127.0.0.1  */

Tags:

Sql Example