PHP MySql (1045) Access Denied For User

后端 未结 4 1390
轻奢々
轻奢々 2020-12-07 02:51

I\'ve tried to search for an existing answer to this problem, but the answers I find have not worked thus far.

I\'ve been attempting to use PHP to connect to a MySql

4条回答
  •  时光说笑
    2020-12-07 03:07

    This worked for me:

    • Depending on what MySQL version you have, make sure you have matching password and hostname on your PHP file, config.inc.php file.

    If you need to change the password for MySQL 5.7.6 and later:

    ALTER USER 'root'@'localhost' IDENTIFIED BY 'MyNewPass';
    

    MySQL 5.7.5 and earlier:

    SET PASSWORD FOR 'root'@'localhost' = PASSWORD('MyNewPass');
    
    • If you are trying to access your localhost server from a different machine i.e. (emulator, another computer), make sure you are using the actual IP address of the the localhost, DO NOT USE localhost as the hostname. Because this is like telling the machine to connect to itself - but the server is on a different IP address.

提交回复
热议问题