用户root的访问被拒绝-MAC OS上的mysql [英] Access denied for user root - mysql on MAC OS

查看:265
本文介绍了用户root的访问被拒绝-MAC OS上的mysql的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道如何在ubuntu上跳过此问题,但是如何在MAC OS上做到这一点?

I know how do skip this problem on ubuntu, but how can i do it on MAC OS?

如何在MAC上为mysql设置密码?

How can i set password for mysql on MAC?

1)不起作用

mysqladmin -u root password NEWPASSWORD

2)不起作用

mysqld --skip-grant-tables --skip-networking &

3)可行:

忘记了mysql root密码

推荐答案

您可以在Mac(El Capitan)上执行以下操作

You can do the following on Mac (El Capitan)

  1. 打开终端"窗口,如果已经运行mysql,请使用以下命令停止mysql.

  1. Open a Terminal window, use the command below to stop mysql if it's already running.

sudo /usr/local/mysql/support-files/mysql.server stop

您还可以检查系统偏好设置">"MySQL"以查看其是否正在运行

You can also check System Preferences > MySQL to see if it is running

使用以下命令启动MySQL:

Start MySQL with this command:

sudo /usr/local/mysql/bin/mysqld_safe --skip-grant-tables

打开一个新的终端窗口/标签:

Open a new terminal window/tab:

sudo /usr/local/mysql/bin/mysql -u root

这应该打开"mysql"提示.执行以下命令:

This should open "mysql" prompt. Execute the following command:

$mysql> UPDATE user SET authentication_string=PASSWORD("my_password") WHERE User='root';

故障排除提示:

A)5.7之前的MySql版本的命令为:

A) The command for MySql versions before 5.7 was:

$mysql> UPDATE user SET Password=PASSWORD('my_password') where USER='root';

B)如果看到ERROR 1046 (3D000): No database selected,请先运行以下命令:

B) If you see ERROR 1046 (3D000): No database selected, then run this command first:

use mysql;

C)如果看到未知的密码"字段错误,请运行以下命令:

C) If you see unknown "Password" field error, then run this command:

UPDATE USER SET AUTHENTICATION_STRING=password('NewPassword') WHERE user='root'; $mysql> FLUSH PRIVILEGES; $mysql> EXIT

UPDATE USER SET AUTHENTICATION_STRING=password('NewPassword') WHERE user='root'; $mysql> FLUSH PRIVILEGES; $mysql> EXIT

停止MySql服务器

sudo /usr/local/mysql/support-files/mysql.server stop

通过系统偏好设置">"MySql"或使用命令来重新启动MySQL.

Restart MySQL, either through System Preferences > MySql or using a command.

这篇关于用户root的访问被拒绝-MAC OS上的mysql的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆