[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1742
  • Last Modified:

MySQL Error 1045: Access Denied for User

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 newserver.com -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'@'example.com' (using password: YES)". The username and host are masked. The odd thing is that it is displaying "@example.com" when that is actually the host of the new server, and example.net 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?
0
coreyward
Asked:
coreyward
  • 2
1 Solution
 
KashraCommented:
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 oldserver.com and newserver.com 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.
0
 
coreywardAuthor Commented:
I actually just figured out what you were trying to say at the same time. I failed to remove trucex.com 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.
0
 
coreywardAuthor Commented:
Scratch that. It appears that it is working after all.
0

Featured Post

Free learning courses: Active Directory Deep Dive

Get a firm grasp on your IT environment when you learn Active Directory best practices with Veeam! Watch all, or choose any amount, of this three-part webinar series to improve your skills. From the basics to virtualization and backup, we got you covered.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now