PHP - MySQL access denied error - Works in other programs

前端 未结 3 1018
一向
一向 2021-01-25 17:46
Access denied for user \'root \'@\'localhost\' (using password: YES)

Yes, this error is all too common, and I have spent much time researching it. How

相关标签:
3条回答
  • 2021-01-25 18:00

    Your connection should be like this

    $link = mysql_connect('127.0.0.1:3307', 'mysql_user', 'mysql_password');
    

    do not include http, add the port number to like in the example, check user name and password.

    If will annoy you but each time you use a mysql_* function you'll get a PDO recommendation. I also recommend PDO, PHP also recomments PDO, you can check PHP Documentation for mysql_connect

    0 讨论(0)
  • 2021-01-25 18:09

    Something is wrong with your credentials.

    Verify the:

    • Username
    • Password
    • Host

    Also, please stop using mysql_* functions as they are now deprecated. Use MySQLi or PDO instead.

    0 讨论(0)
  • 2021-01-25 18:10

    You have 'root[SPACE]' as the user name. Try 'root' without the space?

    0 讨论(0)
提交回复
热议问题