mac下mysql 1045 (28000): Access denied for user 'root'@'localhost' (using password:
新入了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:的更多相关文章
- 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 ...
- 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 ...
- 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 ...
- 解决MySQL5.7在MAC下登录ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)问题
问题描述 今天在MAC上安装完MYSQL后,MYSQL默认给分配了一个默认密码,但当自己在终端上使用默认密码登录的时候,总会提示一个授权失败的错误:ERROR 1045 (28000): Access ...
- 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 ...
- [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 ...
- 【转载】重置密码解决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 ...
- 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.找到配 ...
- 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,客户端连 ...
随机推荐
- mysql更新子查询中的内容
UPDATE t_finance_certify_copy c SET c.biz_type=2,c.sub_biz_type=18WHERE c.finance_certify_id IN(SELE ...
- NIO 01 (转)
本文转自:http://www.cnblogs.com/littlehann/p/3720396.html 目录 1. NIO.NIO.2简介 2. NIO中的关键技术 1. NIO.NIO.2简介 ...
- Ubuntu16.04 Xmind安装
Ubuntu16.04 Xmind安装: 官网下载:直接下载不用注册: 到下载目录选择下载文件右键,提取到此处(为登录用户权限):在终端采用root权限解压为root权限(unzip xmind-8- ...
- C++之操作Excel(抄录https://www.cnblogs.com/For-her/p/3499782.html)
MFC操作Excel 下面的操作基于Excel2003 一.初始化操作 1.导入类库 点击查看->建立类向导-> Add Class...\From a type Library...-& ...
- CentOS6.5安装Qt4.8.6+QtCreator2.6.1
工作中需要用到Qt在Linux下做开发,公司提供的电脑安装的CentOS6.2,但是为了和windows下自己使用的QT版本一直,于是也选择安装了Qt5.1.0.但是在CentOS下刚开始是无法启动, ...
- Python3.x:报错POST data should be bytes, an iterable of bytes
Python3.x:报错POST data should be bytes, an iterable of bytes 问题: python3.x:报错 POST data should be byt ...
- 20145312 实验四《Andoid开发基础》
20145312 实验四<Andoid开发基础> 实验内容 1. 安装Android Studio 2. 运行安卓AVD模拟器 3. 使用Android运行出模拟手机并显示自己的学号 实验 ...
- shell脚本中使用什么工具进行计算
1.答: expr 2. expr的用法: jello=$(expr 1 \* 3) //乘法,注意1和expr之间有空格,1与转换符\之间有空格,3和*之间有空格 jello=$(expr 1 / ...
- 采用OpenReplicator解析MySQL binlog
Open Replicator是一个用Java编写的MySQL binlog分析程序.Open Replicator 首先连接到MySQL(就像一个普通的MySQL Slave一样),然后接收和分析b ...
- Numpy 数据分析基础
numpy 库 ndarray : numpy 的关键 a = np.array([1,2,3]) # 轴 a.ndim # 数组长度 a.size # 数组的型 a.shape # 类型 a.dty ...