我刚刚在Mac上安装了MySQL。下一步是设置根用户密码,所以我接下来这样做:
$ cd /usr/local/mysql/bin $ ./mysqladmin -u根密码' password '
但是,当我执行以下命令时
$ ./mysql -u root,这是答案:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 224
Server version: 5.5.13 MySQL Community Server (GPL)
Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql>我不需要任何密码就可以进入mysql命令行!
为什么会这样呢?
发布于 2011-06-25 07:58:53
当您登录到MySQL终端时,尝试命令FLUSH PRIVILEGES。如果这不起作用,那么在MySQL终端中尝试执行以下命令集
$ mysql -u root
mysql> USE mysql;
mysql> UPDATE user SET password=PASSWORD("NEWPASSWORD") WHERE User='root';
mysql> FLUSH PRIVILEGES;
mysql> quit将NEWPASSWORD更改为您想要的任何密码。应该都设置好了!
更新:从MySQL 5.7开始,password字段已重命名为authentication_string。更改密码时,请使用以下查询更改密码。所有其他命令保持不变:
mysql> UPDATE user SET authentication_string=PASSWORD("NEWPASSWORD") WHERE User='root';更新口令:在8.0.15 (可能在该版本之前)上,()函数不起作用,如下面的评论所述。你必须使用:
UPDATE mysql.user SET authentication_string='password' WHERE User='root';
发布于 2014-04-04 08:10:58
如果您不记得为root设置的密码,需要重置密码,请执行以下步骤:
运行服务器
sudo mysqld_safe --skip-grant-tables;
在新窗口中的
mysql -u root
对于早于MySQL 5.7的MySQL,请使用:
UPDATE mysql.user SET Password=PASSWORD('your-password') WHERE User='root';
对于MySQL 5.7+使用:
USE mysql;
UPDATE mysql.user SET authentication_string=PASSWORD("your-password") WHERE User='root';
刷新并退出:
FLUSH PRIVILEGES;
\q
发布于 2012-04-17 06:35:23
一旦您安装了MySQL,您将需要建立“根”密码。如果您没有建立root密码,那么就没有root密码,并且您不需要密码即可登录。
因此,也就是说,您需要建立一个root密码。
使用终端输入以下内容:
安装:设置root用户密码:
/usr/local/mysql/bin/mysqladmin -u root password NEW_PASSWORD_HERE如果您犯了错误,或者需要更改root密码,请使用以下命令:
更改超级用户密码:
cd /usr/local/mysql/bin/
./mysql -u root -p
> Enter password: [type old password invisibly]
use mysql;
update user set password=PASSWORD("NEW_PASSWORD_HERE") where User='root';
flush privileges;
quithttps://stackoverflow.com/questions/6474775
复制相似问题