MySql ERROR 1045 (00000): Access denied - different MySQL versions - mysql

I need to get an old MySQL Client (4.1) to connect to an even older MySQL Server (3.23).
The goal is to do a Java/JDBC connect to the old Linux/MySQL 3.23 database, in order to update text information for a Lucene search (which will also run on linuxdev2).
The problem is that I can't connect to the Linux/MySQL 3.23 server from a remote Linux/MySql 4.1 client. I can't connect from JDBC; I can't connect from "mysql":
LOCAL (intranet):
mysql -uSOMEUSER -pSOMEPASSWORD mysql => OK
REMOTE (from linuxdev2):
mysql -uSOMEUSER -pSOMEPASSWORD -hintranet mysql => FAILS:
ERROR 1045 (00000): Access denied for user: 'SOMEUSER#linuxdev2' (Using password: YES)
PERMISSIONS (on intranet):
mysql> select User,Host,Password from user order by User;
+-----------+-----------------------------+------------------+
| User | Host | Password |
+-----------+-----------------------------+------------------+
| SOMEUSER | % | 233780be35015f2c |
| SOMEUSER | localhost | 233780be35015f2c |
| ...
These are the hosts:
Component Intranet: Linuxdev2:
--------- -------- ---------
Java N/A Sun Java 1.5.0_03
JDBC N/A mysql-connector-java-3.1.6-3
MySQl Server mysql-server-3.23.22-6 mysql-4.1.10a-3.8
MySql Client mysql-3.23.22-6 mysql-client-4.1.10a-3
I took an Ethereal trace and verified the TCP/IP connection from linuxdev2 to intranet is OK:
a) They connect on port 3306
b) Linuxdev2 does a "Login request Caps"
c) Intranet replies with "Response Error Code: 415" (access denied)

MySQL's password algorithm changed in v4.1 - the same password() function, but different hashing algorithms, so connecting with a v4.1+ client to an older v3.x server using password()-created passwords won't work.
Ref: http://dev.mysql.com/doc/refman/5.1/en/password-hashing.html

Related

MySQL2 Gem Acces Denied but Login via Terminal Works

I'm running a rake task and attempting to create a database connection to mysql via the mysql2 gem but for some reason I am getting this error:
*** Mysql2::Error Exception: Access denied for user 'user'#'localhost' (using password: YES)
This is the connection code:
Mysql2::Client.new(host: server, database: db, username: user, password: pwd)
There are two reasons this is strange:
I am able to use the same credentials to login via the terminal
I created a VM (centos 7) and added a mysql database and uploaded the dump.sql file and was able to login just fine via the terminal and by using the MySQL2 gem. So I know that code works, I'm just not sure why it doesn't work for the mysql instance it is running on.
I've checked the user privileges and my user has all the necessary privileges, the database is running on localhost, I've tried setting the host parameter to 127.0.0.1 and got the same error.
Calling this: mysql> select USER(), CURRENT_USER(); returns the following:
+--------------------+----------------+
| USER() | CURRENT_USER() |
+--------------------+----------------+
| user#localhost | user#% |
+--------------------+----------------+
1 row in set (0.00 sec)
Calling this:
mysql> Select SUBSTRING_INDEX(host,':',1) as 'ip' From information_schema.processlist WHERE ID=connection_id();
returns:
+-----------+
| ip |
+-----------+
| localhost |
+-----------+
My MySQL version is 5.7.17 for linux, running on CentOS 7.
Any ideas why this wouldn't work for one Centos/MySql version and it would for another and why I can login though the terminal and can't in my code?
Login via the terminal reset a new password, and it must can connect by new password via the mysql2 gem

Rails can't connect to external mysql server despite Privileges

I run rails on my local dev environment but the mysql instance is on a separate server.
When trying to open a page in the app I get this error:
Access denied for user 'username'#'myhostname.lan' (using password: YES)
When I ssh into the server running mysql and run this command SELECT Host from mysql.user WHERE User='username'; I get the following:
+---------------------+
| Host |
+---------------------+
| % |
| myhostname.lan |
| localhost |
+---------------------+
All of these entries were created with GRANT ALL PRIVIELEGES ON dbname.* TO ...
So why can I not connect given that both the any-host wildcard % is in the list as well as the hostname I try to connect from specifically?
Despite having same usernames these users are different for mysql.
Check that the password is set on all user entries and is what you expect it to be.
You can compare authentication_strings in mysql.user.

"127.0.0.1" option specified, but still using "localhost" name

I'm using the -h option, specifying that I want to connect to MySQL Server via a specific host/interface, but MySQL is telling me this, which apparently doesn't make so much sense
root#ilg40:/# mysql -h 127.0.0.1 -u root -proot
mysql: [Warning] Using a password on the command line interface can be insecure.
ERROR 1698 (28000): Access denied for user 'root'#'localhost'
OBS.: I have created a access for root via 127.0.0.1 (FLUSH PRIVILEGES() was already performed.
root#ilg40:/# mysql -e "SELECT User,Host,authentication_string FROM mysql.user;"
+-----------+-----------+-------------------------------------------+
| User | Host | authentication_string |
+-----------+-----------+-------------------------------------------+
| root | localhost | |
| mysql.sys | localhost | *THISISNOTAVALIDPASSWORDTHATCANBEUSEDHERE |
| root | 127.0.0.1 | *81F5E21E35407D884A6CD4A731AEBFB6AF209E1B |
+-----------+-----------+-------------------------------------------+
Have you guys any idea about what's going on?
I can't find where is my failure :(..
P.S: I'm using Debian Jessy + MySQL 5.7.12
root#ilg40:/# cat /etc/debian_version
8.4
root#ilg40:/# mysql -e "SELECT VERSION();"
+-----------+
| VERSION() |
+-----------+
| 5.7.12 |
+-----------+
Acoording to MySQL official doc:
"The server performs host name resolution using the thread-safe
gethostbyaddr_r() and gethostbyname_r() calls if the operating system
supports them.
Otherwise, the thread performing the lookup locks a mutex
and calls gethostbyaddr() and gethostbyname() instead.
In this case, no other thread can resolve host names that are not in the host
cache until the thread holding the mutex lock releases it."
The solution I found was: dropping the user 'root'#'localhost' from MySQL.
DROP USER 'root'#'localhost';
I tried to modify the /etc/hosts, but no good. There's something else around the way that MySQL performs these two syscalls, which maps 127.0.0.1 to localhost, independently if you the address mapped in a different way in /etc/hosts.
WARNING: be sure to have at least another user with admin powers on MySQL, using 127.0.0.1 for connection, or else, you may loose access and/or admin powers over MySQL.

What is the difference between the host values in "Current user" vs "Connection" (in mysql status)

I am troubleshooting a MySQL privileges problem.
I want to connect to MySQL on the local server, but refer to it by it's LAN name (so I can use the same user/pass/host on several web-nodes).
I have included credentials in the privilege tables for both a %.lan and a localhost user.
mysql> select user,host from mysql.user where user = 'mysqluser';
+-----------+---------------------+
| user | host |
+-----------+---------------------+
| mysqluser | %.lan |
| mysqluser | localhost |
+-----------+---------------------+
However, when I try to login, I get the error message
[systemuser#servername.mydomain.com ~]$ mysql -u mysqluser -p -h servername.mydomain.com.lan
Access denied for user 'mysqluser'#'servername.mydomain.com'
Note that servername.mydomain.com.lan does resolve to a 192.168.% IP; i.e. it's in my /etc/hosts file. Moreover, reverse DNS for the IP in question resolves as expected.
[systemuser#servername.mydomain.com ~]$ dig -x 192.168.X.Y
...
;; ANSWER SECTION:
Y.X.168.192.in-addr.arpa. 86400 IN PTR servername.mydomain.com.lan.
If I temporarily grant privileges to 'mysqluser'#'%' and login, MySQL reports
mysql> status
...
Current user: mysqluser#servername.mydomain.com
...
Connection: servername.mydomain.com.lan via TCP/IP
...
Why is the host for my Current user not equal to the host for my Connection?
What I am doing/assuming incorrectly? I should note that my arrangement was working as intended (for weeks), on two farms on a common LAN, then both, independent MySQL instances suddenly started rejecting MySQL connections.

Bizarre MySQL Workbench error on Linux desktop

I have an account with a Java PaaS (CloudBees) that hosts their platform off of Amazon EC2 instances. My account comes with access to a MySQL server instance and I am getting a bizarre error that only occurs when I try to log into the MySQL server from a client on my linux (Ubuntu 12.04 desktop) machine, but not my Windows 7 machine.
Here is a screenshot of the error when I try to log in with MySQL Workbench on my Ubuntu machine:
It's important to note that I have another MySQL client (Squirrel SQL) installed on this machine, that throw the same exact error when I try to log in to my dl_web account. Squirrel SQL is a pure Java application, and I have tried to check that MySQL Workbench and Squirrel SQL do not share any common dependencies and couldn't find any (but I could be wrong).
However, when I try to log in with a MySQL Workbench instance living on my Windows 7 machine, I can log in just fine.
Given the list of 4 things to check from that error message:
Yes, of course MySQL server is running on the EC2 instance; otherwise CloudBees would be out of business and I wouldn't be able to log in from my Windows 7 machine.
3306 is the correct port - I verified this with CloudBees support staff.
Not sure about this one - perhaps the MySQL server instance is somehow configured to refuse connections from linux clients?!?!
The password I'm using is correct - I have checked and re-checked and re-re-checked.
So the only 2 theories I have so far are:
The MySQL server instance is somehow configured to refuse connections from Linux clients (is this even possible?); or
The MySQL Workbench and Squirrel SQL instances on my Ubuntu machine are sharing some common dependency that is buggy or misconfigured; this is the more likely of the two scenarios, but I have been unsuccessful pegging down what this dependency is...
Also - note the exact error message that I get from both MySQL Workbench and Squirrel SQL:
Access denied for user 'dl_web'#'%' to database...
My user is dl_web...not 'dl_web'#'%'!!! Bizarre, right?!
Any ideas? Thanks in advance!
You appear to be in a hosted environment within AWS where you do not have access to root or to view grants on tables, but this may help someone else and show a few steps.
first, if I go into sqlyog (or toad or mysql workbench) and try to connect to AWS mysql, i get the following error:
http://img836.imageshack.us/img836/4594/out1.GIF
so the issue is root#pool-72-93-207-216.bstnma.fios.verizon.net
so i get into mysql at root (yes I know you might not be able to do this !)..
and I perform the following
mysql> use test;
mysql> grant all privileges on test.* to 'root'#'pool-72-93-207-216.bstnma.fios.verizon.net' identified by 'mypassword123z';
mysql> select user,host from mysql.user;
+------------------+--------------------------------------------+
| user | host |
+------------------+--------------------------------------------+
| foo_user | % |
| root | 127.0.0.1 |
| foo_user | 72.93.207.216 |
| foo_user2 | 72.93.207.216 |
| root | ::1 |
| | domU-12-31-38-04-B2-89 |
| root | domU-12-31-38-04-B2-89 |
| | localhost |
| debian-sys-maint | localhost |
| phpmyadmin | localhost |
| root | localhost |
| root | pool-72-93-207-216.bstnma.fios.verizon.net |
+------------------+--------------------------------------------+
mysql> SHOW GRANTS FOR 'root'#'localhost';
+----------------------------------------------------------------------------------------------------------------------------------------+
| Grants for root#localhost |
+----------------------------------------------------------------------------------------------------------------------------------------+
| GRANT ALL PRIVILEGES ON *.* TO 'root'#'localhost' IDENTIFIED BY PASSWORD '*4F4504C8CA8D22648E58B5092F653457698A9EBE' WITH GRANT OPTION |
| GRANT PROXY ON ''#'' TO 'root'#'localhost' WITH GRANT OPTION |
+----------------------------------------------------------------------------------------------------------------------------------------+
mysql> show grants for 'root'#'pool-72-93-207-216.bstnma.fios.verizon.net';
+----------------------------------------------------------------------------------------------------------------------------------------------+
| Grants for root#pool-72-93-207-216.bstnma.fios.verizon.net |
+----------------------------------------------------------------------------------------------------------------------------------------------+
| GRANT USAGE ON *.* TO 'root'#'pool-72-93-207-216.bstnma.fios.verizon.net' IDENTIFIED BY PASSWORD '*CACE4BB4D0A5D265BA7FCBEED600DC8976884A43' |
| GRANT ALL PRIVILEGES ON `test`.* TO 'root'#'pool-72-93-207-216.bstnma.fios.verizon.net' |
+----------------------------------------------------------------------------------------------------------------------------------------------+
then I go back to sqlyog (or toad or mysql workbench) and log in with root and password mypassword123z and I am in.
in addition you can create an secure SSH proxy tunnel thru port 22 and your AWS pem file, using like Putty.