[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

#1045 - Access denied for user 'root'@'localhost' (using password: NO)  - please help

Posted on 2011-09-14
9
Medium Priority
?
1,203 Views
Last Modified: 2012-05-12
I'm EXTREMELY new to MySQL.  I just installed a wamp server on my windows 7 machine as instructed. Everything else works but this Myphpadmin.  I'm getting this error but have no idea how to fix it.  Please assist.  Thanks!
0
Comment
Question by:LB1234
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
  • 2
9 Comments
 
LVL 111

Expert Comment

by:Ray Paseur
ID: 36536641
Try running this script... Show us the output.  Hint: You may need to GRANT privileges for it to work.
<?php // RAY_mysql_example.php
error_reporting(E_ALL);


// THE ABSOLUTE MINIMUM YOU MUST UNDERSTAND TO USE PHP AND MYSQL
// MAN PAGE: http://php.net/manual/en/ref.mysql.php
// MAN PAGE: http://php.net/manual/en/mysql.installation.php
// MAN PAGE: http://php.net/manual/en/function.mysql-connect.php
// MAN PAGE: http://php.net/manual/en/function.mysql-select-db.php
// MAN PAGE: http://php.net/manual/en/function.mysql-real-escape-string.php
// MAN PAGE: http://php.net/manual/en/function.mysql-query.php
// MAN PAGE: http://php.net/manual/en/function.mysql-errno.php
// MAN PAGE: http://php.net/manual/en/function.mysql-error.php
// MAN PAGE: http://php.net/manual/en/function.mysql-num-rows.php
// MAN PAGE: http://php.net/manual/en/function.mysql-fetch-assoc.php
// MAN PAGE: http://php.net/manual/en/function.mysql-fetch-array.php
// MAN PAGE: http://php.net/manual/en/function.mysql-insert-id.php



// CONNECTION AND SELECTION VARIABLES FOR THE DATABASE
$db_host = "localhost"; // PROBABLY THIS IS OK
$db_name = "??";        // GET THESE FROM YOUR HOSTING COMPANY
$db_user = "??";
$db_word = "??";


// OPEN A CONNECTION TO THE DATA BASE SERVER
if (!$db_connection = mysql_connect("$db_host", "$db_user", "$db_word"))
{
    $errmsg = mysql_errno() . ' ' . mysql_error();
    echo "<br/>NO DB CONNECTION: ";
    echo "<br/> $errmsg <br/>";
}

// SELECT THE MYSQL DATA BASE
if (!$db_sel = mysql_select_db($db_name, $db_connection))
{
    $errmsg = mysql_errno() . ' ' . mysql_error();
    echo "<br/>NO DB SELECTION: ";
    echo "<br/> $errmsg <br/>";
    die('NO DATA BASE');
}
// IF THE SCRIPT GETS THIS FAR IT CAN DO QUERIES
echo "SUCCESS!";

Open in new window

0
 
LVL 1

Author Comment

by:LB1234
ID: 36536672

( ! ) Warning: mysql_connect() [function.mysql-connect]: Access denied for user '??'@'localhost' (using password: YES) in C:\wamp\www\php_sandbox\test.php on line 40
Call Stack
#      Time      Memory      Function      Location
1      0.0020      676512      {main}( )      ..\test.php:0
2      0.0020      677600      mysql_connect ( )      ..\test.php:40

NO DB CONNECTION:
1045 Access denied for user '??'@'localhost' (using password: YES)

( ! ) Warning: mysql_select_db() expects parameter 2 to be resource, boolean given in C:\wamp\www\php_sandbox\test.php on line 48
Call Stack
#      Time      Memory      Function      Location
1      0.0020      676512      {main}( )      ..\test.php:0
2      0.0091      678112      mysql_select_db ( )      ..\test.php:48

NO DB SELECTION:
1045 Access denied for user '??'@'localhost' (using password: YES)
NO DATA BASE
0
 
LVL 31

Accepted Solution

by:
Marco Gasi earned 2000 total points
ID: 36536742
First, try to see if PhpMyAdmin config file has correct values in Wamp you shoud open C:\wamp\apps\phpmyadmin3.3.9 (accordingly with your version) and look for config.inc.php: open it in a text editor and look for these lines

$cfg['Servers'][$i]['user'] = '';
$cfg['Servers'][$i]['password'] = '';
$cfg['Servers'][$i]['AllowNoPassword'] = true;

Ensure that values for username and password are correct.

If this doesn't solve your problem tell me and I give a way to reset mysql password: I had the same problem but now all works fine.
0
Moving data to the cloud? Find out if you’re ready

Before moving to the cloud, it is important to carefully define your db needs, plan for the migration & understand prod. environment. This wp explains how to define what you need from a cloud provider, plan for the migration & what putting a cloud solution into practice entails.

 
LVL 1

Author Comment

by:LB1234
ID: 36536798
Thanks Marqus, but at no point did i set a username or password (nor was i prompted for one during the WAMP installing).  It was all next > next > finish basically.

Here's what i have for the lines you mentioned.  If I enter something for username and password, what should it be?  As mentioned, there won't be any corresponding values elsewhere.

$cfg['Servers'][$i]['user'] = 'root';
$cfg['Servers'][$i]['password'] = '';
$cfg['Servers'][$i]['AllowNoPassword'] = true;
0
 
LVL 31

Expert Comment

by:Marco Gasi
ID: 36536976
Well. Can you access to phpMyAdmin and open Privileges tab? If yes, do it and check values you find there and tell me about, please.
0
 
LVL 1

Author Comment

by:LB1234
ID: 36536991
I don't know what's happened but it works now :(

I didn't do anything, but I wish i knew what the resolution was.

Thanks all for your help!
0
 
LVL 31

Expert Comment

by:Marco Gasi
ID: 36537012
Something it happens... :-) Good luck with your project.
0
 
LVL 111

Expert Comment

by:Ray Paseur
ID: 36537032
Regarding the post at ID:36536672... You got this message:

1045 Access denied for user '??'@'localhost' (using password: YES)

See lines 21-25 of the script.  You might want to put your own credentials in there.
0
 
LVL 31

Expert Comment

by:Marco Gasi
ID: 36537072
Thanks for points, but since I have not solved your problem you can consider to request attention of a moderator to change your decision and split points between me and Ray. I have to notice that in your original question you got error saying 'using password: NO' and later you got an error saying 'using password: YES': this sounds strange to me...
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Originally, this post was published on Monitis Blog, you can check it here . In business circles, we sometimes hear that today is the “age of the customer.” And so it is. Thanks to the enormous advances over the past few years in consumer techno…
In this article, we’ll look at how to deploy ProxySQL.
The viewer will get a basic understanding of what section 508 compliance can entail, learn about skip navigation links, alt text, transcripts, and font size controls.
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
Suggested Courses

649 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question