Solved

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

Posted on 2011-09-13
4
290 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 109

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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
SonarQube on Linux vs Windows 3 28
php string detection problem 7 34
What is linux 4.8.22? Is it the same as ubuntu 16.10 ?? 2 41
Email called spam 5 14
Since pre-biblical times, humans have sought ways to keep secrets, and share the secrets selectively.  This article explores the ways PHP can be used to hide and encrypt information.
When table data gets too large to manage or queries take too long to execute the solution is often to buy bigger hardware or assign more CPUs and memory resources to the machine to solve the problem. However, the best, cheapest and most effective so…
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.:
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

832 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