Solved

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

Posted on 2011-09-13
4
283 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 108

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 17

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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Developers of all skill levels should learn to use current best practices when developing websites. However many developers, new and old, fall into the trap of using deprecated features because this is what so many tutorials and books tell them to u…
This article discusses four methods for overlaying images in a container on a web page
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:
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 …

708 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now