My wp config create
command:
wp core config --dbname=wordpress --dbuser=wordpress --dbpass='this is not the real password'
Running it:
$ wp core config --dbname=wordpress --dbuser=wordpress --dbpass='this is not the real password'
ERROR 1045 (28000): Access denied for user 'wordpress'@'localhost' (using password: YES)
Some evidence about why I think the problem is that wp-cli is trying to use the '\@localhost version' of the user I'm specifying; from the MariaDB 'monitor':
MariaDB [(none)]> SELECT Host, User FROM mysql.user;
+-----------+-----------+
| Host | User |
+-----------+-----------+
| % | wordpress |
| 127.0.0.1 | root |
| ::1 | root |
| localhost | |
| localhost | root |
+-----------+-----------+
This didn't work either:
$ wp core config --dbhost=\% --dbname=wordpress --dbuser=wordpress --dbpass='this is not the real password'
ERROR 2005 (HY000): Unknown MySQL server host '%' (8)
How can I tell wp-cli to use the '% version' of the wordpress user?
A seemingly relevant GitHub issue for the wp-cli project:
- wp config create ERROR 1045 (28000): Access denied for user · Issue #4505 · wp-cli/wp-cli
My wp config create
command:
wp core config --dbname=wordpress --dbuser=wordpress --dbpass='this is not the real password'
Running it:
$ wp core config --dbname=wordpress --dbuser=wordpress --dbpass='this is not the real password'
ERROR 1045 (28000): Access denied for user 'wordpress'@'localhost' (using password: YES)
Some evidence about why I think the problem is that wp-cli is trying to use the '\@localhost version' of the user I'm specifying; from the MariaDB 'monitor':
MariaDB [(none)]> SELECT Host, User FROM mysql.user;
+-----------+-----------+
| Host | User |
+-----------+-----------+
| % | wordpress |
| 127.0.0.1 | root |
| ::1 | root |
| localhost | |
| localhost | root |
+-----------+-----------+
This didn't work either:
$ wp core config --dbhost=\% --dbname=wordpress --dbuser=wordpress --dbpass='this is not the real password'
ERROR 2005 (HY000): Unknown MySQL server host '%' (8)
How can I tell wp-cli to use the '% version' of the wordpress user?
A seemingly relevant GitHub issue for the wp-cli project:
- wp config create ERROR 1045 (28000): Access denied for user · Issue #4505 · wp-cli/wp-cli
2 Answers
Reset to default 1You probably have an anonymous user ' '@'localhost' or ' '@'127.0.0.1' in MariaDB. The recommended solution is to drop this anonymous user (this is usually a good thing to do anyways).
For users setup as an 'all hosts' user, i.e. the value of Host
in the table mysql.user
for the row for that user is '%'
, there's nothing that needs to be done. wp-cli WILL try to connect as the 'localhost version' of that user, but doing so should be fine if the user really is an 'all hosts' user.
--dbhost=\%
? But it looks a bit wierd, in my opinion. I have never seen this before. Is%
perhaps just a placeholder for127.0.0.1
? Perhaps try with--dbhost=127.0.0.1
. It's a long-shot. Sorry. :-/ – Zeth Commented Nov 3, 2018 at 11:32dbhost
is telling the config, which host that the database is located on. So then you should insert the IP-address of the host where the database is located. Or am I missing something? – Zeth Commented Nov 3, 2018 at 11:43wp core config ...
command, but perhaps not. – Kenny Evitt Commented Nov 3, 2018 at 14:00