mysql - mysql@5.7 上的访问被拒绝
问题描述
我在 macos 上通过 brew 安装了包 mysql@5.7,以便可以使用 Laravel,按照当前文档但我无法访问 mysql@5.7
$ mysql -u root -p
Enter password:
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)
文件说
数据库
如果您需要数据库,请在命令行上运行 brew install mysql@5.7 来尝试使用 MySQL。安装 MySQL 后,您可以使用 brew services start mysql@5.7 命令启动它。然后,您可以使用 root 用户名和空字符串作为密码连接到位于 127.0.0.1 的数据库。
我进行了长时间的研究,发现这是一个非常普遍的问题,但是我尝试的任何方法都不起作用
我启动了mysqld
跳过刷新权限,但随后也无法 root,mysql -u root -p
我尝试运行php artisan cache:clear
我尝试使用 sudo -s 以 root 身份登录以及其他目前不记得的事情(基本上是 3 天我很忙)我是真的很惊讶,像 Laravel 这样应该很简单的框架,有这种文档教程和 laracast 都没有报告的问题,我没有做任何奇怪的事情,只是按照指南
解决方案
我看到一个帖子,建议更改密码,但在这种情况下我也遇到了一些问题,所以我不得不结合不同的响应,但现在我主要关注这篇帖子 ,但到达了第 5 点:
5:修改您的密码您的新密码应输入“()”
I had to deal with a change in mysql@5.7 namely if you do show tables
you see that there is not a password column anymore, so you get an error message that does not exist the column password,
so I just passed
update user set authentication_string=password('1111') where user='root';// please notice 1111 is the password you fill
as indicated in this other post
then I followed the other step indicated by the post, to flush privileges and quit
finally I started again the daemon with
$brew services start mysql@5.7
and $mysql -u root -p (herethepassword)
did not work so I did
$mysql --password=(herethepassword) --user=root
and worked
推荐阅读
- sql - 在 Rails 上插入查询错误
- python - 如何检索 numpy.array 的维度
- java - android:无法构建项目错误:无法从中读取包名
- c# - IoT Edge SendEventBatchAsync
- pandas - 累积总和数据帧的条件计数 - 遍历列
- c# - 机器人模拟器登录
- php - 将数据和图像(所有内容)从 Wordpress 导出到另一个页面
- sql-server - SQL Server - 分配白天和黑夜
- postgresql - Windows 10 上的 PostgreSQL 10.5 无效的语言环境名称
- excel - 与任何 Excel 操作进行上下文同步时发生内部错误