I'am facing "Error establishing a database connection" by setting up wordpress on macOS. Here is my steps:
- Using Wordpress 5.5 (https://wordpress.org/download/)
- wp-config.php
// ** MySQL settings - You can get this info from your web host ** //
/** The name of the database for WordPress */
define( 'DB_NAME', 'wordpress_database_***' );
/** MySQL database username */
define( 'DB_USER', 'db_user' );
/** MySQL database password */
define( 'DB_PASSWORD', 'db_pass' );
/** MySQL hostname */
define( 'DB_HOST', 'localhost' );
/** Database Charset to use in creating database tables. */
define( 'DB_CHARSET', 'utf8' );
/** The Database Collate type. Don't change this if in doubt. */
define( 'DB_COLLATE', '' );
- Create db + user by commandline
$ sudo mysql -u admin -p
mysql> CREATE DATABASE db_name;
mysql> CREATE USER 'db_user'@'localhost' IDENTIFIED BY 'db_pass';
mysql> GRANT ALL PRIVILEGES ON db_name.* TO 'db_user'@'localhost';
mysql> FLUSH PRIVILEGES;
mysql> exit
$ sudo mysql.server restart
$ sudo nginx // start nginx
- Finally, I load mydomain.com (config in vhosts). And be always getting issues ("Error establishing a database connection")
Anyone experienced, pease give me some helps, Thanks