linux报错 Access denied for user 'root'@'localhost' (using password: YES)
时间: 2023-08-28 13:04:15 浏览: 121
回答: 当在Linux上执行数据库操作时,如果出现"Access denied for user 'root'@'localhost' (using password: YES)"的错误,可能是由于权限问题导致的。一种解决方法是按照以下步骤进行操作:首先,以管理员方式打开终端;然后进入mysql/bin目录;接着,输入"mysqld --skip-grant-tables"命令启动MySQL服务并跳过权限表认证;再打开一个终端窗口,同样转到mysql/bin目录下;在新的终端窗口中,输入"mysql"命令,如果成功,将出现MySQL提示符">";连接权限数据库:使用命令"use mysql;";接下来,使用命令"update user set authentication_string=password('your new password') where user='root';"修改密码(请将"your new password"替换为你想要设置的新密码);刷新权限,使用命令"flush privileges;";退出MySQL,使用命令"quit;";最后,重新登录系统,使用用户名root和刚才设置的新密码登录。这样,应该可以解决"Access denied for user 'root'@'localhost' (using password: YES)"的问题。请注意,上述步骤可能需要管理员权限才能执行。<span class="em">1</span><span class="em">2</span><span class="em">3</span>
#### 引用[.reference_title]
- *1* *2* [Access denied for user root @ localhost (using password: YES)](https://blog.csdn.net/weixin_67925067/article/details/129630161)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v92^chatsearchT0_1"}}] [.reference_item style="max-width: 50%"]
- *3* [mysql5.7版本1045 报错 Access denied for user root@localhost (using password: YES)](https://blog.csdn.net/weixin_48504959/article/details/123745664)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v92^chatsearchT0_1"}}] [.reference_item style="max-width: 50%"]
[ .reference_list ]
阅读全文