当通过自制(即brew install mysql@5.7)在MacOS Mojave上安装mysql时,一个看似成功的安装会打印以下说明:
We've installed your MySQL database without a root password. To secure it run:
mysql_secure_installation
MySQL is configured to only allow connections from localhost by default
To connect run:
mysql -uroot当运行mysql -uroot或mysql_secure_installation时,我会得到以下错误:
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)如何登录到mysql以更改root密码
发布于 2018-12-04 15:50:50
通过--password标志使用“空字符串”密码似乎解决了这个问题:
mysql -uroot --password=""或者,您可以使用mysqld手动启动--skip-grant-tables。
$ mysql.server --skip-grant-tables
$ mysql
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.7.24 Homebrew
Copyright (c) 2000, 2018, 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.
$ 最后,用以下方式更改密码:
mysqladmin -uroot --password="" password NEW_PASSWORD发布于 2019-03-22 01:54:18
在新的brew mysql安装之后:
1)确保mysql正在运行: brew服务启动mysql
2)更改mysql密码: mysqladmin -uroot --密码=“密码'NEWPASSWORD‘
3)安全mysql: mysql_secure_installation (使用新密码)
发布于 2019-10-17 02:06:23
我认为所有在安装后运行mysql_secure_installation命令的人都会遇到这样的麻烦。
我们需要附加用户名和密码参数才能理解如下:
mysql_secure_installation -u root --password=""https://stackoverflow.com/questions/53616701
复制相似问题