新入了mac pro,安装好mysql后,用终端进入mysql遇到个问题: 1045 (28000): Access denied for user 'root'@'localhost' (using password: N

讲道理,我还设密码呢,但是第一次进来就报错,goo了一下大概原因可能是mysql创建的时候给自动分配了密码。

不管分配没分配密码,反正一般的解决方法就是:先跳过验证,再重设密码。

具体步骤:

1. 先关闭MySQL服务;
执行

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

或者在系统偏好设置中关闭MySQL服务(如果电脑有设置密码的,此处会要求输入计算机密码)

2.去mysql文件夹里设置跳过验证(3步)

先进入mysql文件夹:
cd /usr/local/mysql/bin/
设置权限,如果电脑有设置密码(开机和解锁计算机时要求输入的那个密码),在输入此句后会要求输入密码。输入密码后按回车确认
sudo su
跳过验证
./mysqld_safe --skip-grant-tables &

3.开始设置我们自己的新密码

打开一个新的终端,输入

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

然后会要求输入密码,因为此时根本没有密码,所以直接点确认,显示以下信息表示成功进入mysql(与windows系统一样)

Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 20
Server version: 5.7.11 Copyright (c) 2000, 2016, 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>

现在设置新密码,注意要打引号:

UPDATE mysql.user SET authentication_string=PASSWORD('cc77') where User='root';

回车确认,显示以下信息表示修改密码成功

Query OK, 1 row affected, 1 warning (0.00 sec)
Rows matched: 1 Changed: 1 Warnings: 1

然后刷新一下,让上述修改生效:

flush privileges;

刷新成功会显示以下信息:

Query OK, 0 rows affected (0.01 sec)

4.重启mysql,用新密码登录,可以登录成功了。但是进行其他mysql操作,会显示:

ERROR 1820 (HY000) :You must reset your password using AlTER USER statement before executing this statement.

意思是还要再重设一遍密码,直接输入:

SET PASSWORD = PASSWORD('cc77');

修改成功后,终端会显示:

Query OK, 0 rows affected, 1 warning (0.01 sec)

至此,修改密码彻底完成,可以做任何相关sql操作了

mac下mysql 1045 (28000): Access denied for user 'root'@'localhost' (using password:的更多相关文章

  1. mac系统中搭建apache+mysql+php的开发环境,安装mysql后,登录报错:mac ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)

    php新手在mac系统中搭建apache+mysql+php的开发环境(按照这篇博客来操作的:http://my.oschina.net/joanfen/blog/171109?fromerr=xvC ...

  2. Ubuntu下 MySQL的“ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)”

    今天闲来无事,在Ubuntu上掏鼓一下mysql.但尴尬的是,当我输入mysql -u root -p的时候,抛出了一个错误:ERROR 1045 (28000): Access denied for ...

  3. Ubuntu下MySQL报错:ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)

    在Ubuntu下 想要登录mysql数据库 root@JD:~# mysql -uroot -p 报错 ERROR 1045 (28000): Access denied for user 'root ...

  4. 解决MySQL5.7在MAC下登录ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)问题

    问题描述 今天在MAC上安装完MYSQL后,MYSQL默认给分配了一个默认密码,但当自己在终端上使用默认密码登录的时候,总会提示一个授权失败的错误:ERROR 1045 (28000): Access ...

  5. Linux下登陆MySQL时遇到报错"RROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES) "

    前言 作者在2021-07-21时遇到 linux下登陆MySQL时遇到报错"RROR 1045 (28000): Access denied for user 'root'@'localh ...

  6. [mysql] ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES).

    用mysql -u root -p显示ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YE ...

  7. 【转载】重置密码解决MySQL for Linux错误 ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)

    重置密码解决MySQL for Linux错误 ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using passwor ...

  8. MySQL在登陆时出现ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)错误

    错误显示:ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES) 解决方案: 1.找到配 ...

  9. mysql安装在centos7报错ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)

    原文链接:http://blog.csdn.net/kuluzs/article/details/51924086 [问题]:mysql版本:5.7.13 首次在centos下安装MySQL,客户端连 ...

随机推荐

  1. java 加密解密

    https://www.cnblogs.com/kingsleylam/category/752546.html <java加密与解密艺术>代码可抄袭.

  2. oracle过程书写规范

    ORACLE存储过程编码规范 1.1         变量规范 Ø        变量名全部采用小写,局部变量名使用“v_”开头,输入参数以“i_开头,输出参数以“o_”开头,输入输出参数用io_开头 ...

  3. 【英语学习】How do I stop overthinking at night?

    2017-04-03 If you were to say to the grown-ups: "I saw a beautiful house made of rosy brick, wi ...

  4. JavaScript&jQuery获取url参数方法

    JavaScript&jQuery获取url参数方法 function getUrlParam(name){ var reg = new RegExp("(^|&)" ...

  5. go channel 阻塞

    初接触 go 有不对得请解释下 Channel是goroutine之间进行通信的一种方式,先看下面代码为什么会阻塞: func closer(ch chan int) { ch <- 1 log ...

  6. sqlx基础语法与应用

    基础: ``` 引用:_ "github.com/go-sql-driver/mysql" "github.com/jmoiron/sqlx" ``` 初始化 ...

  7. 开发人员不可不看的 OBD通讯协议知识

    OBD-II Network Standards» J1850 VPW– Adopted by GM; also known as Class 2.– Adopted by Chrysler (kno ...

  8. Activiti工作流与spring集成

    一.前言 前面Activiti工作流的学习,说明了Activiti的基本应用,在我们开发中可以根据实际的业务参考Activiti的API去更好的理解以及巩固.我们实际的开发中我们基本上都使用sprin ...

  9. c++之单例模式

    1 本篇主要讨论下多线程下的单例模式实现: 首先是 double check 实现方式: 这种模式可以满足多线程环境下,只产生一个实例. template<typename T> clas ...

  10. vc libcurl 模拟上传文件

    http://www.cnblogs.com/killbit/p/5393301.html 附上这篇文章,因为当时就已经想到了模拟上传,但是因为时间关系,所以就直接用PHP写了.现在改进一下,用VC+ ...