[英]MySQL 5.7.20 unable to set root password
I installed MySQL Server 5.7.20 on ubuntu 14.04 and i can log in to server using: 我在ubuntu 14.04上安装了MySQL Server 5.7.20,可以使用以下命令登录到服务器:
mysql -u root -p
password is blank...how can i set mysql root password in terminal before install mysql server? 密码为空...在安装mysql服务器之前,如何在终端中设置mysql根密码?
I installed it using silent install and try to run from terminal this mysql query: 我使用静默安装安装了它,并尝试从终端运行此mysql查询:
SET PASSWORD FOR 'root'@'localhost' = 'mypasswordhere';
But i im getting this: 但我得到这个:
Query OK, 0 rows affected, 1 warning (0.00 sec)
mysql> SHOW warnings;
+-------+------+------------------------------------------------------------------------------------------------------------+
| Level | Code | Message |
+-------+------+------------------------------------------------------------------------------------------------------------+
| Note | 1699 | SET PASSWORD has no significance for user 'root'@'localhost' as authentication plugin does not support it. |
+-------+------+------------------------------------------------------------------------------------------------------------+
1 row in set (0.00 sec)
So what i im doing wrong? 那么我在做什么错呢? I just want to change from blank password for user root to mypasswordhere password...how it needs to be done?
我只想从root用户的空白密码更改为mypasswordhere密码...该怎么做?
Try 尝试
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'mypasswordhere';
From https://www.percona.com/blog/2016/03/16/change-user-password-in-mysql-5-7-with-plugin-auth_socket/ 从https://www.percona.com/blog/2016/03/16/change-user-password-in-mysql-5-7-with-plugin-auth_socket/
If you install 5.7 and don't provide a password to the root user, it will use the auth_socket plugin.
如果您安装了5.7,并且没有提供密码给root用户,它将使用auth_socket插件。 That plugin doesn't care and doesn't need a password.
该插件无关紧要,不需要密码。 It just checks if the user is connecting using a UNIX socket and then compares the username.
它只是检查用户是否正在使用UNIX套接字进行连接,然后比较用户名。 If we want to configure a password, we need to change the plugin and set the password at the same time, in the same command.
如果要配置密码,则需要在同一命令中同时更改插件和设置密码。
After installing Mysql on Ubuntu and similar one should run mysql_secure_installation command . 在Ubuntu和类似版本上安装Mysql之后,应运行mysql_secure_installation命令。
It clears some possible problems and one of the things is it asks for a new root password. 它清除了一些可能的问题,其中之一就是要求输入新的root密码。
But previous answer from @Valuator will change the password. 但是@Valuator的先前答案将更改密码。
user1433049 suggests to use mysql_secure_installation. user1433049建议使用mysql_secure_installation。 However, this does not help: Also mysql_secure_installation does not change the root password in this situation.
但是,这无济于事:在这种情况下,mysql_secure_installation不会更改root密码。 That's what brought me here.
那就是把我带到这里的原因。
(This is actually a comment/correction to the answer above. However, I cannot comment due to low reputation. If someone can transfer it to a comment, please delete this answer.) (这实际上是对上面答案的评论/更正。但是,由于信誉不佳,我无法发表评论。如果有人可以将其转移为评论,请删除此答案。)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.