MySQL Error 1045: Access Denied for User

Posted on 2007-07-27
Last Modified: 2013-12-16
I'm swapping my websites from one server (Debian) to another (RHEL), more powerful, server. I can't afford much downtime, and the site uses MySQL for VIP member signups. I installed MySQL 5 on the new RHEL server and moved over all of the data from the old server (mysqldump > file > mysql). I'm trying to swap the websites on the old server to use the database on the new server (different location) before I move the site over so both the new server and old server have websites running on the same data.

I've configured the users on the new MySQL. I set the user to allow connections from anybody (%) and granted it limited access to the needed databases. I flushed the privileges and connected from my local machine to the server via MySQL Administrator as well as MySQL Query Browser without a hitch.

I then popped into the old server and tried to connect to the new server via " $: mysql -h -u username -pPASSWD databasename" and I got an Error 1045. I also connected from my CentOS server that is at the same location as the new RHEL server via command line without a problem.

Exact error message is "ERROR 1045 (28000): Access denied for user 'user'@'' (using password: YES)". The username and host are masked. The odd thing is that it is displaying "" when that is actually the host of the new server, and is the host of the old server.

Old Server: Ver 14.12 Distrib 5.0.32, for pc-linux-gnu (i486) using readline 5.2
New Server: Ver 14.12 Distrib 5.0.45, for pc-linux-gnu (i686) using readline 5.0
Tested From: Ver 14.7 Distrib 4.1.20, for redhat-linux-gnu (i686) using readline 4.3

What's going on?
Question by:coreyward
    LVL 3

    Accepted Solution

    Well, as you've been able to connect to the new server using other systems, that suggests that you've set up your permissions correctly, at least.

    The only possibility I can think of that would explain the output you observe is if the mysql client is really connecting to the local host on the old server (say the old server's DNS thinks and both point to localhost). Then you'd be trying to connect to the old database which (assumedly) does not have the same user/password combination.

    You could try shutting down the new server and executing the command on the old server. If it still connects and gives you that error, obviously its connecting to itself and not the new host. If it times out, there goes that theory.
    LVL 2

    Author Comment

    I actually just figured out what you were trying to say at the same time. I failed to remove from the DNS on the old server, so it was attempting to connect to itself. I am able to connect to the new server via IP.

    I'm still not getting a connection through PHP though, even when I specify an IP address.
    LVL 2

    Author Comment

    Scratch that. It appears that it is working after all.

    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.

    Join & Write a Comment

    I annotated my article on ransomware somewhat extensively, but I keep adding new references and wanted to put a link to the reference library.  Despite all the reference tools I have on hand, it was not easy to find a way to do this easily. I finall…
    Shadow IT is coming out of the shadows as more businesses are choosing cloud-based applications. It is now a multi-cloud world for most organizations. Simultaneously, most businesses have yet to consolidate with one cloud provider or define an offic…
    Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…
    Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

    728 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

    19 Experts available now in Live!

    Get 1:1 Help Now