Unable to connect to database: Access denied for user ''@'localhost' to database 'socialdb'

后端 未结 6 1124
野趣味
野趣味 2021-01-21 11:07

I\'ve seen a few errors like this, but I found no answer.

Unable to connect to database: Access denied for user \'\'@\'localhost\' to database \'socialdb\'


        
相关标签:
6条回答
  • 2021-01-21 11:44

    mysql_connect takes 3 parameters

    $con = mysql_connect("localhost", "dbuser", "password");
    
    0 讨论(0)
  • 2021-01-21 11:46

    Your default credentials are most likely:

    $con = mysql_connect("localhost","root","");
    
    0 讨论(0)
  • 2021-01-21 11:48

    You did not specify a user in neither mysql_connect or your PHP configuration.

    Either set mysql.default_user and mysql.default_password in your PHP configuration or use the appropriate arguments for mysql_connect.

    0 讨论(0)
  • 2021-01-21 11:49

    even if you are not having a user. there exist 'root' user so use it

    $con = mysql_connect('localhost','root','');
    
    0 讨论(0)
  • 2021-01-21 12:07

    You're missing username and password parameter, should be:

    $con = mysql_connect("localhost","username","password");
    
    0 讨论(0)
  • 2021-01-21 12:08

    The error is pretty self-explanatory, you're not allowed to connect without specifying some credentials.

    Change your call to mysql_connect() to something like this:

    mysql_connect("localhost", "user", "password");
    
    0 讨论(0)
提交回复
热议问题