WP-CLI not using the correct MySQL user
-
Summary:
I’ve installed the wp-cli.phar into a project. I can’t install the file into a bin directory of our production server so I have to run commands like so php wp-cli.phar.
We do the same locally, each project as its own WP-CLI. Running commands locally works perfectly.
We run into issues when using it on production. Somehow, WP-CLI can’t find the correct MySQL user (the one defined into the wp-config.php) when running commands. This triggers errors on the Terminal like Warning: mysqli_real_connect(): (HY000/1045): Access denied for user ‘server-db’@’localhost’ where server-db is nowhere to be found.
Steps to reproduce:
Install wp-cli.phar into your project
Push it live
Try to run commands on a virtual private server using php wp-cli.phar
Environment:What is your system?
No LSB modules are available.
Distributor ID: Debian
Description: Debian GNU/Linux 8.8 (jessie)
Release: 8.8
Codename: jessieWhich version of PHP are you using?
/usr/bin/php
php 7.0.1Which version of WordPress are you using?
4.8.1
Can you share the results of which wp ?
1.3.0
Are you running any packages? If one is causing a problem, you can use –skip-packages to skip
No.
Results and impacts:
Severity
High
Expected results
Being able to run any commands
Actuel results
MySQL error message Warning: mysqli_real_connect(): (HY000/1045): Access denied for user ‘server-db’@’localhost’
I’ve also posted the error to our provider. They perhaps might give us a hint but would like to know if anyone has ever had this issue.
Or is it possible to define a database user to use when running commands?
- The topic ‘WP-CLI not using the correct MySQL user’ is closed to new replies.