20190629 mac 上安装过 mysql 和 phpmyadmin之后,很久没有使用(本机硬盘空间有限),今天想用的时候,死活输入不对密码了!

以前处理过的 mysql 忘记密码处理,都是在 linux 上的

思路和处理方式是一样的,但是具体操作起来,mac 上还是不一样!

1、参考

https://blog.csdn.net/liu_yanzhao/article/details/79427005

开始没有明白参考博客中 “ 回车后 登录管理员权限 sudo su ” ,实际照着操作一下就明白了!
开始总以为和过去的 sudo + 命令 方式一样的!
以下就是我的错误过程

$ sudo ./mysqld_safe --skip-grant-tables &

[1] 2070
dhbm-on-mac20180816:bin dhbm$ sudo ./mysqld_safe --skip-grant-tables &./mysql
[2] 2105
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)[1]+  Stopped                 sudo ./mysqld_safe --skip-grant-tables## 2、

$ sudo ./mysql

Password:
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)[4]+  Stopped                 sudo ./mysqld_safe --skip-grant-tables

2、我的过程记录

请原谅!其实我都是照抄的!
  1. 查找我的 mysql 在哪里
    $ which mysql
    /usr/local/mysql/bin/mysql

  2. 进入 su
    $ sudo su
    sh-3.2#

    这是重点!后续实际上和 linux 上一样了
    后续命令都是在这个 # 方式下

  3. 禁止mysql验证功能
    sh-3.2# ./mysqld_safe --skip-grant-tables &
    返回结果如下:

     [1] 2141sh-3.2# 2019-06-29T08:05:37.6NZ mysqld_safe Logging to '/usr/local/mysql-5.7.21-macos10.13-x86_64/data/dhbm-on-mac20180816.local.err'.2019-06-29T08:05:38.6NZ mysqld_safe Starting mysqld daemon with databases from /usr/local/mysql-5.7.21-macos10.13-x86_64/data
    
  4. sh-3.2# ./mysql
    返回结果如下:

     Welcome to the MySQL monitor.  Commands end with ; or \g.Your MySQL connection id is 6Server version: 5.7.21 MySQL Community Server (GPL)Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.Oracle is a registered trademark of Oracle Corporation and/or itsaffiliates. Other names may be trademarks of their respectiveowners.Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
    

这就进入到 mysql> 命令方式了

5.mysql> FLUSH PRIVILEGES;
返回结果如下:

Query OK, 0 rows affected (0.00 sec)

6.mysql> SET PASSWORD FOR ‘root’@‘localhost’ = PASSWORD(‘123456’);
返回结果如下:

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

整个过程如下所示:

3、测试一下

再打开一个 Terminal
$ mysql -u root -p
返回结果如下:

 Enter password: Welcome to the MySQL monitor.  Commands end with ; or \g.Your MySQL connection id is 486Server version: 5.7.21 MySQL Community Server (GPL)Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.Oracle is a registered trademark of Oracle Corporation and/or itsaffiliates. Other names may be trademarks of their respectiveowners.Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.mysql

打开浏览器
http://localhost/phpMyAdmin-4.8.0.1-all-languages/index.php
输入 root /123456 之后
还是错误啊!

mysqli_real_connect(): (HY000/2002): No such file or directory

4、 mysqli_real_connect(): (HY000/2002): No such file or directory 错误处理

正好我使用了 PHPStorm 打开了这个 phpmyadmin,目录结构一目了然
如下图所示,直接复制一份 config.sample.php 到 config.inc.php
命令行方式这里就不再列举了!不是重点!
No such file or directory 指的是没有 config.inc.php 这个文件!

修改以下 2 处
//cfg[′Servers′][cfg['Servers'][cfg[′Servers′][i][‘host’] = ‘localhost’;
//by wzh 20190629
cfg[′Servers′][cfg['Servers'][cfg[′Servers′][i][‘host’] = ‘127.0.0.1’;

//cfg[′Servers′][cfg['Servers'][cfg[′Servers′][i][‘password’] = ‘’;
// by wz h20190629 123456
cfg[′Servers′][cfg['Servers'][cfg[′Servers′][i][‘password’] = ‘123456’;

再次测试
http://127.0.0.1/phpMyAdmin-4.8.0.1-all-languages/index.php

Mac mysql 忘记 root 密码,phpmyadmin 登录 No such file or directory 错误处理相关推荐

  1. Mac MySQL忘记root密码

    Mac MySQL忘记root密码 本文转载自Mac MySql忘记root密码! 刚刚在Mac上安装了下MySQL,但是发现不知道root密码是什么!所以,查找别人的博客,亲测可用,做个记录. 第一 ...

  2. Linux下使用MySQL——忘记root密码及修改MySQL默认编码

    概述: 本博客不再对MySQL的语法进行讲解和说明,想了解或熟悉的朋友请自行百度或Google学习.本博客主要是针对MySQL除语法之外的总结,希望能够也能帮助到你. 1.CentOS6.x下MySQ ...

  3. win上mysql忘记root密码_MySQL数据库之windows下mysql忘记root密码的解决方法

    本文主要向大家介绍了MySQL数据库之windows下mysql忘记root密码的解决方法 ,通过具体的内容向大家展现,希望对大家学习MySQL数据库有所帮助. 方法一: 1.在DOS窗口下输入net ...

  4. 附录:MySQL忘记root密码

    中小型规模网站集群架构:MySQL忘记root密码 : Ago linux运维群:93324526 前言 你忘记系统root密码的时候,你怎么解决的? 不就是single用户进行修改密码吗?这里原理是 ...

  5. Ubuntu下MySQL忘记root密码重置

    MySQL忘记root密码肿么办?-_-|||   这种情况虽然不是很常见,但是有时长时间没有登录系统,还真会忘记密码.这时候,如果您能以系统管理员权限登陆密码,那还是有救的.放大招,将其重置即可. ...

  6. linux mysql 忘记root密码_Linux MySQL忘记root密码解决方案

    在使用MySQL数据库时,由于某些原因长时间没有登陆MySQL,或者由于工作交接完成度不高,导致数据库root登陆密码忘记,如何解决? 一.更改my.cnf配置文件 1.用命令编辑/etc/my.cn ...

  7. Mysql 忘记root密码的完美解决方法

    一.更改my.cnf配置文件 1.用命令编辑/etc/my.cnf配置文件,即:vim /etc/my.cnf 或者 vi /etc/my.cnf 2.在[mysqld]下添加skip-grant-t ...

  8. linux mysql root免密_Linux下MySQL忘记root密码的完美解决方法

    在使用MySQL数据库时,由于某些原因长时间没有登陆MySQL,或者由于工作交接完成度不高,导致数据库root登陆密码忘记,本文给大家介绍一种当忘记MySQL root密码时的解决办法,亲测有效. 首 ...

  9. 查询电脑上mysql的密码忘记了怎么办_windows下mysql忘记root密码的解决方法 -电脑资料...

    方法一: 1.在DOS窗口下输入net stop mysql5 或 net stop mysql 2.开一个DOS窗口,这个需要切换到mysql的bin目录, 一般在bin目录里面创建一个批处理1.b ...

  10. MySQL忘记root密码不重启mysqld的方法

    MySQL忘记root密码不重启mysqld的方法 1.首先得有一个可以拥有修改权限的mysql数据库账号,当前的mysql实例账号(较低权限的账号,比如可以修改zabbix数据库)或者其他相同版本实 ...

最新文章

  1. 【转】android开发工具Eclipse,androidStudio,adt网盘下载--不错
  2. 数梦工场联手阿里云 推出大数据一体机
  3. 内存中的rank跟bank有什么区别
  4. matplotlib各个部分
  5. 架构师最怕程序员知道的十件事
  6. Django Form -- 字段的用法扩展
  7. LightOJ 1370 Bi-shoe and Phi-shoe(欧拉函数)
  8. linux安装mysql5.5.52,Linux系统上安装MySQL 5.5prm
  9. 【论文学习】Spatially Variant Linear Representation Models for Joint Filtering
  10. 6-5 java简介
  11. flutter 自定义键盘_Flutter 引擎架构
  12. 广告投入是怎样提高新用户数的(岭回归及主成分回归) | R语言商业分析实践3
  13. Ajax的工具类AjaxUtils,使用struts返回Json类型
  14. CPC23-4-K. 喵喵的神数 (数论 Lucas定理)
  15. 【提升笔记本续航】WIN10笔记本打开电源选项中的处理器电源管理
  16. 十月美剧精听总结 - 权力的游戏「Game of Throne」 黑袍纠察队「The boys」 老无所依「No Country for the old men」
  17. 什么是响应式Web设计?
  18. 网络计算典型形态的发展回顾和愿景展望
  19. 【项目实战】登录与注册业务的实现(前端+后端+数据库)
  20. 8820c自动化测试软件,8820C LTE测试操作手册

热门文章

  1. python语法简图
  2. UIViewController的生命周期
  3. JAVA学习笔记(五)
  4. 四则运算生成器做法思路
  5. 七牛上传图片问题总结
  6. UITextView(文本视图) 学习之初体验
  7. Python 学习随笔
  8. 验证只能以英文字母开头的字符串
  9. Tarjan在图论中的应用(二)——用Tarjan来求割点与割边
  10. 一周水题集锦 2017 9.4