admin管理员组文章数量:1130349
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.
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
-
1
Maybe:
--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:32 - @Zeth The '%' host means 'all hosts', i.e. that user can connect to the MySQL or MariaDB instance from any host. The '\@localhost' users can only connect from the same host as on which the DB server is running. – Kenny Evitt Commented Nov 3, 2018 at 11:37
-
1
Ahh..! I see. But is the database on your local machine? The
dbhostis 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:43 - @Zeth The database server instance is on my local machine. But it seems useful for the user to be able to connect from another host (other than the host on which the DB server instance is running), e.g. if I wanted to host the DB server and WordPress app on separate machines. – Kenny Evitt Commented Nov 3, 2018 at 13:29
-
It turned out to be a dumb error; the password for the user in wp-config.php was missing the single quote character in it. I'm pretty sure I quoted it correctly in my
wp core config ...command, but perhaps not. – Kenny Evitt Commented Nov 3, 2018 at 14:00
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.
本文标签:
版权声明:本文标题:wp cli - How to specify to wp-cli for the `wp config create` (`wp core config`) command that the DB user is an 'all host 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:https://it.en369.cn/questions/1749208479a2332966.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。


--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:32dbhostis 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