Solved

access denied for user " "@localhost MySql but can log in through access

Posted on 2011-09-13
4
292 Views
Last Modified: 2012-05-12
Hers a really strange one that I simply cannot figure out.
Every time I or or web app trys to log into the MySql or any other database on our server we get the access denied for " " @localhost.
If I do not provide a database name when logging into MySql I can get in and when I do a show databases I only see
mysql> show databases
    -> ;
+--------------------+
| Database           |
+--------------------+
| information_schema |
+--------------------+
1 row in set (0.00 sec)

Now here's the really weird part. I CAN get into any database from my PC using access (I downloaded the free mysql driver).
So why can't I log in at the console of the server? How can I fix this?
Help please!
0
Comment
Question by:edwarddoylesr
  • 2
4 Comments
 
LVL 110

Expert Comment

by:Ray Paseur
ID: 36529174
Here is my teaching example of how to do some of the basics in PHP and MySQL.  Copy it and install it on your server, substitute your own credentials at line 22-25 and see if it works for you.
<?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 18

Expert Comment

by:Garry-G
ID: 36529234
Did you allow for the user to connect from localhost? Please note there is a difference from the ACL point of view between 127.0.0.1 and localhost ...

For tests, do something like this as admin user:

   grant all privileges on DBNAME.* to 'USERNAME'@'localhost' identified by 'USERPASSWD';

after that, the usual "mysql_connect" call followed by the "mysql_select_db" ought to work fine ...
0
 

Accepted Solution

by:
edwarddoylesr earned 0 total points
ID: 36529844
It turned out to be a bad my.conf file.
I used my backup copy and I can now log in.

Thanks all,
0
 

Author Closing Comment

by:edwarddoylesr
ID: 36555797
The only difference I saw was the bind statement in the backup was not in the my.conf
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Load balancing is the method of dividing the total amount of work performed by one computer between two or more computers. Its aim is to get more work done in the same amount of time, ensuring that all the users get served faster.
Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

679 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