'mysqli::real_connect(): (HY000/1045): Access denied for user 'root'@'localhost' (using password: NO) error on Mac

This is the error message I got after I tried to make a password and username for localhost and root. Please help me. I am using Mac by the way.

MySQL said: Documentation

Cannot connect: invalid settings.

mysqli::real_connect(): (HY000/1045): Access denied for user 'root'@'localhost' (using password: NO)

phpMyAdmin tried to connect to the MySQL server, and the server rejected the connection. You should check the host, username and password in your configuration and make sure that they correspond to the information given by the administrator of the MySQL server.



Solution 1:[1]

go to xampp\mysql\bin\my.ini and open it. change the port to 3307 and go to xampp\phpMyAdmin\config.inc.php and check the name of the host $cfg['Servers'][$i]['host'] = 'localhost:3307';

Solution 2:[2]

Adding to soufiane's answer above, there is actually 2 more places where you have to make the same change:

  1. xampp window: config > Service and Port Settings > mysql > Change port to 3307
  2. add $cfg['Servers'][$i]['port'] = 3307; to phpMyAdmin\config.inc.php

For a complete start to finish solution, refer to this answer on Quora by Owais R. Mir: https://www.quora.com/How-do-I-change-the-port-of-a-MySQL-server-in-XAMPP/answer/Owais-R-Mir

PS: I used this solution to run mysql from xampp on port 3307 because I had installed mysql separately before and it was using port 3306. When ports are reset for xampp mysql you avoid issues with initializing and signing in to your local database via phpmyadmin.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 soufiane_ben_yaala
Solution 2 MIRAU