-1

When I try to load a website from /var/www/html/ it reports this error:

PHP Warning:  mysqli::__construct(): (HY000/1698): Access denied for      user 'root'@'localhost'

It says that the raw responsible for the issue is this

$link = new mysqli($server, $username, $password, $database);

How can I fix this problem?

StackUser
  • 1,530
  • 3
  • 13
  • 17

1 Answers1

0

Verify the permission tables on the server and that you're connecting to the correct server.

You must allow remote login on MySQL server to root user using the command below

Allow from localhost

GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost' IDENTIFIED BY PASSWORD '*root_user_password' WITH GRANT OPTION 

Allow from anywhere

GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY PASSWORD '*root_user_password' WITH GRANT OPTION 

Allow from some host

GRANT ALL PRIVILEGES ON *.* TO 'root'@'X.X.X.X' IDENTIFIED BY PASSWORD '*root_user_password' WITH GRANT OPTION 

Above command must be followed by FLUSH PRIVILEGES; restart on MySQL service

That combination of username, host, and password is not allowed to connect to the server.

DevLoots
  • 747
  • 1
  • 6
  • 21