Mac mysql 忘记 root 密码,phpmyadmin 登陆 No such file or directory 错误处理

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

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

思路和处理方式是同样的,可是具体操做起来,mac 上仍是不同!

一、参考

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

开始没有明白参考博客中 “ 回车后 登陆管理员权限 sudo su ” ,实际照着操做一下就明白了! 开始总觉得和过去的 sudo + 命令 方式同样的! 如下就是个人错误过程mysql

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

[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## 二、

$ sudo ./mysqlsql

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

二、个人过程记录

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

  2. 进入 su $ sudo su sh-3.2#浏览器

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

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

    [1] 2141
     sh-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 返回结果以下:.net

    Welcome to the MySQL monitor.  Commands end with ; or \g.
     Your MySQL connection id is 6
     Server 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 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> 命令方式了命令行

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)

整个过程以下所示: 在这里插入图片描述

三、测试一下

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

Enter password: 
	Welcome to the MySQL monitor.  Commands end with ; or \g.
	Your MySQL connection id is 486
	Server 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 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

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

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

四、 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'][$i]['host'] = 'localhost'; //by wzh 20190629 $cfg['Servers'][$i]['host'] = '127.0.0.1';

//$cfg['Servers'][$i]['password'] = ''; // by wz h20190629 123456 $cfg['Servers'][$i]['password'] = '123456';

再次测试 http://127.0.0.1/phpMyAdmin-4.8.0.1-all-languages/index.php 在这里插入图片描述

相关文章
相关标签/搜索