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=xvCsafCe),在安装配置mysql完毕后,登录mysql,报错:mac ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO),折腾很久,终于解决,随手记录下,备忘。
解决方法:
第一步:如果mysql服务正在进行,将之停止。
第二步:在终端中以管理员权限启动mysqld_safe,命令如下:
sudo /usr/local/mysql/bin/mysqld_safe --skip-grant-tables
执行结果如下:
--12T08::.6NZ mysqld_safe Logging to '/usr/local/mysql/data/lyqdeMacBook-Pro.local.err'.
--12T08::.6NZ mysqld_safe Starting mysqld daemon with databases from /usr/local/mysql/data
第三步:不要关闭当前的终端窗口,新建一个终端窗口,输入如下命令,回车登录mysql
/usr/local/mysql/bin/mysql
登录后,看到欢迎信息:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is
Server version: 5.7. MySQL Community Server (GPL) Copyright (c) , , 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>
打开"mysql"这个数据库,SQL如下:
mysql> use mysql;
看到结果:
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A Database changed
mysql>
然后,更新root的密码,SQL如下:
mysql> update user set authentication_string=password('root') where Host='localhost' and User='root';
注意:
①有的版本的mysql中,密码可能存储在password字段中,可以使用"describe user;"命令来查看下表结构再操作
②authentication_string的值一定通过password函数来计算(password('root'))
执行结果如下:
Query OK, row affected, warning (0.01 sec)
Rows matched: Changed: Warnings:
退出mysql(执行sql语句:exit)
最后一步:将mysqld_safe进程杀死,重启mysqld。
可能会遇到的问题
登录mysql
/usr/local/mysql/bin/mysql -uroot -proot
这个时候,如果执行查询之类的操作,比如执行"show databases;",可能会有如下提示:
ERROR (HY000): You must reset your password using ALTER USER statement before executing this statement.
根据提示进行操作,输入如下SQL语句,这个语句的作用是修改root用户的口令为root:
mysql> alter user 'root'@'localhost' identified by 'root';
结果:
Query OK, rows affected
至此,问题解决。
参考:http://stackoverflow.com/questions/13480170/access-denied-for-mysql-error-1045
mac系统中搭建apache+mysql+php的开发环境,安装mysql后,登录报错:mac ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)的更多相关文章
- mysql登录报错:ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)
在MySQL登录时出现Access denied for user 'root'@'localhost' (using password: YES) 拒绝访问 对于出现拒绝访问root用户的解决方案错 ...
- 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 ...
- Mysql修改root用户密码 For Mac 报错:ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)
环境 Mysql版本:5.7.12 操作系统:OSX 10.11 安装文件:.dmg文件 MySQL:mysql-5.7.12-osx10.11-x86_64.dmg(注意5.7跟之前的字段有些不同, ...
- MySQL报错:ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password:NO)
1.关闭mysql # service mysqld stop2.屏蔽权限 # mysqld_safe --skip-grant-table 屏幕出现: Starting demo fro ...
- MAC使用mysql报错:ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)
遇到这种错误,需要重置密码. Step1:停止mysql,命令如下: $ sudo service mysql stop 或者是 $ sudo /usr/local/mysql/support-fil ...
- yum 安装 Mysql error ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES) 开启远程连接 修改登入密码 忘记root密码 配置防火墙规则 随手mark
yum 安装 MYsql: yum install mysql mysql-server mysql-devel -y 1.1 登入报错: ERROR 1045 (28000): Acc ...
- Linux mysql 5.6: ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)
案例环境: 操作系统 :Red Hat Enterprise Linux Server release 5.7 (Tikanga) 64 bit 数据库版本 : Mysql 5.6.19 64 bit ...
- 解决MySQL5.7在MAC下登录ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)问题
问题描述 今天在MAC上安装完MYSQL后,MYSQL默认给分配了一个默认密码,但当自己在终端上使用默认密码登录的时候,总会提示一个授权失败的错误:ERROR 1045 (28000): Access ...
- 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 ...
随机推荐
- flutter 布局
一.Container 一个空白容器 二.Row 行 mainAxisAlignment 主轴对齐 , CrossAxisAlignment 垂直于主轴对齐 三.Column 列 四.ListVie ...
- (21)python Anaconda
1.安装 Anaconda下载镜像 --官网下载太慢 https://mirrors.tuna.tsinghua.edu.cn/help/anaconda/ 下载安装后 2.添加第三方源 管 ...
- (1)java版本
jdk9新增 jshell工具, 类似python的命令行界面.
- HDFS API 学习:几个常用的API
1.Hadoop-1.2.1 API 文档:http://hadoop.apache.org/docs/r1.2.1/api/ 2.几个API: create(Path f) :Opens an FS ...
- 12、Flask实战第12天:子域名
什么是子域名,我们的后台管理系统, 比如cms.heboan.com.配置子域名需要用到蓝图技术: 我现在buleprints下面创建一个cms.py 蓝图 from flask import Blu ...
- git log 查看某文件的修改历史
先进入此文件所在的目录下 1. git log --help 所有的git命令都可以通过git manual查看 在synopsis中可以看到公式 git log [<options>] ...
- luogu P1855 榨取kkksc03
题目描述 以下皆为真实的故事. 洛谷2的团队功能是其他任何oj和工具难以达到的.借助洛谷强大的服务器资源,任何学校都可以在洛谷上零成本的搭建oj并高效率的完成训练计划. 为什么说是搭建oj呢?为什么高 ...
- luogu P1194 买礼物
题目描述 又到了一年一度的明明生日了,明明想要买B样东西,巧的是,这B样东西价格都是A元. 但是,商店老板说最近有促销活动,也就是: 如果你买了第I样东西,再买第J样,那么就可以只花K[I,J]元,更 ...
- [BZOJ 4117] Weather Report
Link: BZOJ 4117 传送门 Solution: 第一次写$Huffman Tree$相关,发现就是个合并果子? 此题可以将每一种情况的概率和排列总数算出,接下来就是按照$Haffman T ...
- [CF865C]Gotta Go Fast
题目大意: 一个游戏关卡有$n(n\le50)$个任务,若在$m$秒内按顺序完成所有任务则算作通过当前关卡.每个关卡有三个属性$a_i,b_i,p_i(1\le a_i<b_i\le100,80 ...