mysqli_real_connect(): (hy000/1045): access denied for user 'root'@'localhost' (using password: yes) code example
Example 1: ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)
sudo service mysql stop
sudo mkdir /var/run/mysqld
sudo chown mysql: /var/run/mysqld
sudo mysqld_safe
mysql -u root mysql
UPDATE mysql.user SET authentication_string=PASSWORD('YourNewPasswordBuddy'), plugin='mysql_native_password' WHERE User='root' AND Host='localhost';
FLUSH PRIVILEGES;
EXIT;
sudo service mysql restart
mysql -u root -p
Example 2: windows error 1045 (28000): access denied for user 'root'@'localhost' (using password: yes)
update user set authentication_string=password('my_password') where user='root';
Example 3: mysqli::real_connect(): (HY000/1045): Access denied for user 'pma'@'localhost' (using password: NO)
$cfg['Servers'][$i]['port'] = '3307';
Example 4: mysqli_real_connect(): (HY000/1698): Access denied for user 'root'@'localhost'
ALTER USER 'root'@'localhost' IDENTIFIED BY 'mysql';
Example 5: mysqli_real_connect(): (28000/1045): Access denied for user 'u0738423'@'www8.aname.net' (using password: YES)
$connection = mysqli_connect('localhost', 'root', '', 'test');
$connection = mysqli_connect('localhost', 'root', 'P@$$w0rd', 'test');