Database access exception accessdeniedforuser'' @ 'localhost' todatabase' xinjisudi'

Source: Internet
Author: User
Database access error Accessdeniedforuser & # x27; & # x27; @ & # x27; localhost & # x27; todatabase & # x27; xinjisudi & # x27; database connection error & nbsp; database Access error Access & nbsp; denied & nbsp; for & nbsp; user & nbsp; @ localhost & nb database Access error Access denied for user ''@ 'localhost' to database' xinjisudi'
Database connection error: database Access error: Access denied for user'' @ 'localhost' to database' xinjisudi'
Database Connection code
$ Conn = mysql_connect ("localhost", "", "") or die ("database server connection error". mysql_error (); // create a database connection
Mysql_select_db ("xinjisudi", $ conn) or die ("database access error". mysql_error (); // open the database
Mysql_query ("set names utf8"); // fix garbled characters
?>
What are your questions?


------ Solution --------------------
$ Conn = mysql_connect ("localhost ","","")

At least none of the usernames are available. if the password is empty, you can still
------ Solution --------------------
Resource mysql_connect ([string server [, string username [, string password [, bool new_link [, int client_flags])

It can be all default values (condition: user name: root, password: None)
If username is not default, it must be the correct user name.
------ Solution --------------------
Reference:
Resource mysql_connect ([string server [, string username [, string password [, bool new_link [, int client_flags])

It can be all default values (condition: user name: root, password: None)
If username is not default, it must be the correct user name.


If you want to set the default value, you should not enter ''. then you can directly write mysql_connect ('localhost.
------ Solution --------------------
It seems that your user does not have the xinjisudi database permission.
You must first use a root account and other management accounts to log on and authorize permissions.
------ Solution --------------------
Contact the administrator and ask him to assign a user name and password as well ..
------ Solution --------------------
Provide the user name even if there is no password.
------ Solution --------------------
The safest way is to create an account with a password and grant the account the permission to access a database.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.