Warning: mysql_connect (): Access denied for user & #39; root & #39; @ & #39; localhost & #39; (using password: YES ),

Source: Internet
Author: User

Warning: mysql_connect (): Access denied for user 'root' @ 'localhost' (using password: YES ),

Http://www.androidren.com/index.php? Qa = 211 & qa_1 = warning-mysql_connect-access-denied-root % 40-localhost-password

The code may be written as follows:

//to make a connection with database$conn = mysql_connect("localhost", "root", "password") or die(mysql_error());

In some cases, you can change it to the following:

$conn = mysql_connect("localhost", "root")Or$conn = mysql_connect("localhost", "root", "")

However, in some cases, the root cause is that the user of your current database is not authorized to access multiple databases.

In fact, the most likely reason is that your database does not exist. O (∩) O Haha ~

The solution is to start the database.

In this case, the performance is as follows:

1. Under the command line:

Forlong401: Documents forlong401 $ sudo mysql -- user = root-p

Enter password:

ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql. sock' (2)

2. on the browser:

Deprecated: Mysql_connect (): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in/Library/WebServer/Documents/qa-include/qa-db.phpOn line68

Warning: Mysql_connect (): Access denied for user 'root' @ 'localhost' (using password: YES) in/Library/WebServer/Documents/qa-include/qa-db.phpOn line68

Cocould not establish database connection. Please check the username, password and hostname in the config file, and if necessary set up the appropriate MySQL user and privileges.

3. on phpmyadmin:

#2002 unable to log on to the MySQL server



Related Article

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.