corcel / corcel

Use WordPress backend with Laravel or any PHP application

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

DB connection error Laravel

humzakhaled opened this issue · comments

  • Corcel Version: *
  • Framework Name & Version: Laravel 8.65
  • PHP Version: 8
  • Database Driver & Version: mysql

Description:

'wordpress' => [ // for WordPress database
'driver' => 'mysql',
'host' => 'localhost',
'database' => 'my_database',
'username' => 'my_user_name',
'password' => 'my_db_password',
'charset' => 'utf8',
'collation' => 'utf8_unicode_ci',
'prefix' => 'wp_',
'strict' => false,
'engine' => null,
],

I've put actual database , username and password credentials in the above array inside config/database.php. All other parameters are same as it is.

I've also rechecked the credentials by logging into phpmyadmin and they are working correct. But when i use them to fetch records from DB, I get the following error.

SQLSTATE[HY000] [1045] Access denied for user 'u363970340_LgAuH'@'localhost' (using password: YES) (SQL: select * from wp_posts where (post_status = publish or (post_status = future and post_date <= 2023-01-17 11:09:11)))

Please guide me on this one.

To fix this issue, please check the following points:

  1. Verify that the database credentials are correct. Make sure that the username and password provided in the config/database.php file match the correct credentials for your database.

  2. Ensure that the user 'u363970340_LgAuH' has permission to access the database from the 'localhost' host. Check the user's permissions in the database to ensure they have adequate privileges to execute queries.

  3. Make sure the database is running and accessible. Verify that the database server is running and that the 'localhost' host is properly configured to connect to the database server.

  4. Check if the config/database.php file is being properly loaded and if the configurations are being applied correctly. Verify that the file is in the correct location and that there are no syntax or configuration errors in the file.

If you have already checked all of these points and are still experiencing the issue, it may be helpful to check the database error logs for more information on the cause of the error.