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
请原谅!其实我都是照抄的!
查找个人 mysql 在哪里 $ which mysql /usr/local/mysql/bin/mysqlmacos
进入 su $ sudo su sh-3.2#浏览器
这是重点!后续实际上和 linux 上同样了 后续命令都是在这个 # 方式下socket
禁止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
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
正好我使用了 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