I installed mysql utilities on my ubuntu server today, so I could use mysqldbcompare, but I just cannot connect to the mysql server with it (localhost). I created an entry into the .mylogin.cnf, using mysql_config_editor, as mentionned into the mysql utilities 1.6 documentation, and printed / tested it (with mysql), and it's ok. But if I try to run any mysql utilities command, it always fail with
ERROR: Access denied for user '****'@'localhost' (using password: YES)
(I put the stars myself instead of my user name).
I spent more than 2 hours searching the web, I have absolutely no clue of what's wrong... any idea ?
EDIT : alright, let's do this step by step First, my versions. Everything is on the same virtual machine : mysql server and client, and mysql utils. My versions are : MySQL server : Ver 14 Distrib 5.7.22 MySQL client : Ver 14 Distrib 5.7.22 MySQL utils : 1.6.1
- First, using phpMyAdmin (which connects correctly to mysql), I create a user named userTest, with host % and password "bonjour!".
- Then, I go to my host terminal, and type the following :
mysql_config_editor set --login-path=test --host=localhost --user=userTest --port=3306 --password
- When asked, I enter the password "bonjour!"
- Then, I try to connect to mysql using the login path (no user is named "test" on the database :
mysql --login-path=test
This connects me to mysql correctly :
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 17
Server version: 5.7.22-0ubuntu0.16.04.1 (Ubuntu)
Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql>
Now I exit mysql and type a simple mysql utils command :
mysqlserverinfo --server=test
And I get
ERROR: Access denied for user 'userTest'@'localhost' using password: YES
-
Are you login as root user?. Either user has no privileges or wrong password.user153556– user1535562018年06月25日 09:24:08 +00:00Commented Jun 25, 2018 at 9:24
-
No, its a user I gave the needed privileges to do this. The password is correct, because if I type "mysql --login-path=exportImport", I can connect correctly. Moreover, it does not work with any of the mysql utilities command, even mysqlserverinfo. Also, I know the command can read the .mylogin.cnf, because the error I get gives the name of the user, and not the name of the login-pathaxiagame– axiagame2018年06月25日 13:20:58 +00:00Commented Jun 25, 2018 at 13:20
2 Answers 2
OK, so my suspicions were correct. The python scripts of mysql utilies use the default "my_print_defaults" utility to get the credentials from a login path. But the my_print_defaults call returns the password as a bunch of stars, unless you call it with -s... So I modified the python script mysql/utilities/common/my_print_defaults.py to call the my_print_defaults executable with -s to get the password too. And now it works.
-
1If you use latest version of mysql utilities (1.6.1-2), here are the modifications to do : sudo
/usr/lib/python2.7/dist-packages/mysql/utilities/common/my_print_defaults.py
. In method_read_group_data(self, group)
, modify the calls tosubprocess.call
just under the comment saying# Group not found; use my_print_defaults to get group data
by adding "-s" as an argument before the group :subprocess.call([self._tool_path, "-s", group], stdout=outfile...
axiagame– axiagame2018年07月08日 16:03:57 +00:00Commented Jul 8, 2018 at 16:03
If you can access mysql shell, run the following commands
UPDATE mysql.user SET host = '%' WHERE host = 'localhost';
Flush privileges;
Then try logging into your utilities
-
I have access to mysql, and the server is on the same host than the mysql client I use and the mysql utils I installed. My own personal user I use to administrate is set to localhost too and I can connect correctly. I'll update the question to be more preciseaxiagame– axiagame2018年06月29日 18:56:34 +00:00Commented Jun 29, 2018 at 18:56