Mac mysql forget the root password, phpmyadmin login No such file or directory Error Handling

After over mysql and phpmyadmin installed on 20190629 mac, long time no use (limited local hard disk space), today would like to use the time, life and death do not enter your password!

Previously treated mysql forgotten password process, we are in linux

Thinking and approach is the same, but the specific operation of it, or not the same on mac!

1, reference

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

Reference is beginning to understand the blog "after login administrator privileges sudo su Enter", shining the actual operation you will understand!
Start always thought of the past and the same way the command sudo +!
Here is my error process

$ 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, the process of recording my

请原谅!其实我都是照抄的!
  1. Where do I find my mysql
    $ Which mysql
    / usr / local / mysql / bin / mysql

  2. 进入Su
    $ Sudo Su
    Sh-3.2 #

    This is the key! Follow-up on linux as a fact and
    subsequent commands are under way in this #

  3. Verification prohibited mysql
    sh-3.2 # ./mysqld_safe --skip-grant -tables &
    returns the following results:

     [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
    return the following results:

     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.
    

It entered into mysql> command the way !

5.mysql> FLUSH PRIVILEGES;
return the following results:

Query OK, 0 rows affected (0.00 sec)

6.mysql> SET PASSWORD FOR 'root' @ 'localhost' = PASSWORD ( '123456');
return result as follows:

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

The whole process is as follows:
Here Insert Picture Description

3, test

Then open a Terminal
$ MySQL -u root -p
returned the following results:

	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

Open your browser
http: //localhost/phpMyAdmin-4.8.0.1-all-languages/index.php
After entering the root / 123456
or wrong ah!

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

4, mysqli_real_connect (): (HY000 / 2002): No such file or directory Error Handling

I just used the PHPStorm opened the phpmyadmin, clear the directory structure
as shown below, to directly copy config.sample.php config.inc.php
command line is no longer listed here! Not the point!
No such file or directory means that no config.inc.php this file!
Here Insert Picture Description
Modify the following at 2
// c f g [ S e r v e r s ] [ cfg['Servers'][ i][‘host’] = ‘localhost’;
//by wzh 20190629
c f g [ S e r v e r s ] [ cfg['Servers'][ i][‘host’] = ‘127.0.0.1’;

// c f g [ S e r v e r s ] [ cfg['Servers'][ i][‘password’] = ‘’;
// by wz h20190629 123456
c f g [ S e r v e r s ] [ cfg['Servers'][ i][‘password’] = ‘123456’;

Test again
http://127.0.0.1/phpMyAdmin-4.8.0.1-all-languages/index.php
Here Insert Picture Description

Published 69 original articles · won praise 10 · views 30000 +

Guess you like

Origin blog.csdn.net/u010953609/article/details/94169229