Bug #90142 mysql_config_editor mixes up hosts between configs
Submitted: 20 Mar 2018 14:50 Modified: 2 Apr 2018 10:00
Reporter: Kevin Markwardt Email Updates:
Status: Verified Impact on me:
None 
Category:MySQL Server: Command-line Clients Severity:S3 (Non-critical)
Version:5.7.21 OS:Ubuntu (5.7.21-0ubuntu0.16.04.1)
Assigned to: CPU Architecture:x86
Tags: mysql_config_editor

[20 Mar 2018 14:50] Kevin Markwardt
Description:
When I create two configurations one after another, the second configuration uses the host from the first configuration.

How to repeat:
bash# mysql_config_editor set --login-path=config1 --host=server1 --port=6032 --user=user1 --password

bash# mysql_config_editor set --login-path=config2 --host=server2 --user=user2 --password

I configure them both.  Then I try and test them, and get the following error

bash# mysql --login-path=config1
ERROR 2003 (HY000): Can't connect to MySQL server on 'server2' (111)

Suggested fix:
Something in the code is mixing up the hosts if the one is configured right after another.  Please fix it so that the the hosts dont get crossed between configs.
[21 Mar 2018 8:35] MySQL Verification Team
Hello Kevin,

Thank you for the report.
I quickly tried to confirm this issue with the provided statements but confirmed that it is working as expected. 

=========
-- hod03
[umshastr@hod03]/export/umesh/server/binaries/GABuilds/mysql-5.7.21: bin/mysql -uroot -S /tmp/mysql_ushastry.sock
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.7.21 MySQL Community Server (GPL)

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> create user 'user1'@'%';
Query OK, 0 rows affected (0.00 sec)

mysql> create user 'user2'@'%';
Query OK, 0 rows affected (0.00 sec)

mysql> grant all on *.* to 'user1'@'%' identified by 'mysql123';
Query OK, 0 rows affected, 1 warning (0.00 sec)

mysql> grant all on *.* to 'user2'@'%' identified by 'mysql12345';
Query OK, 0 rows affected, 1 warning (0.00 sec)

mysql> \q
Bye
[umshastr@hod03]/export/umesh/server/binaries/GABuilds/mysql-5.7.21: bin/mysql_config_editor print --all
[umshastr@hod03]/export/umesh/server/binaries/GABuilds/mysql-5.7.21: bin/mysql_config_editor set --login-path=config1 --host=hod03 --port=3333 --user=user1 --password
Enter password:
[umshastr@hod03]/export/umesh/server/binaries/GABuilds/mysql-5.7.21: bin/mysql_config_editor set --login-path=config2 --host=hod04 --user=user2 --password
Enter password:
[umshastr@hod03]/export/umesh/server/binaries/GABuilds/mysql-5.7.21:
[umshastr@hod03]/export/umesh/server/binaries/GABuilds/mysql-5.7.21: bin/mysql_config_editor print --all
[config1]
user = user1
password = *****
host = hod03
port = 3333
[config2]
user = user2
password = *****
host = hod04

-- hod03 is up, confirmed that --login-path=config1 works 

[umshastr@hod03]/export/umesh/server/binaries/GABuilds/mysql-5.7.21: bin/mysql --login-path=config1
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 5
Server version: 5.7.21 MySQL Community Server (GPL)

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> show grants;
+--------------------------------------------+
| Grants for user1@%                         |
+--------------------------------------------+
| GRANT ALL PRIVILEGES ON *.* TO 'user1'@'%' |
+--------------------------------------------+
1 row in set (0.00 sec)

-- hod04 is down, as expected connection fails

umshastr@hod03]/export/umesh/server/binaries/GABuilds/mysql-5.7.21: bin/mysql --login-path=config2
ERROR 2003 (HY000): Can't connect to MySQL server on 'hod04' (111)

Could you please confirm what exactly you are seeing after setting up login paths(mysql_config_editor print --all)? May be could you remove all login paths and then attempt to see if that helps? 

Thanks,
Umesh

Thanks,
Umesh
[27 Mar 2018 21:44] Kevin Markwardt
I use the proxysql login path, but get an error from the other path's host

root@bastion:~/bastion-proxy# mysql_config_editor print --all
[proxysql]
user = radminuser
password = *****
host = proxysql
port = 6032
[mysql]
user = remote
password = *****
host = mysql_local
root@bastion:~/bastion-proxy# mysql --login-path=proxysql
ERROR 2003 (HY000): Can't connect to MySQL server on 'mysql_local' (111)
[27 Mar 2018 21:45] Kevin Markwardt
Could it be because of the path being "mysql", tomorrow I will test with a different path name.
[27 Mar 2018 21:48] Kevin Markwardt
When i set the proxysql config again, everything works as expected, and in the print all, we can see that the proxysql config is second in the list, not sure how that allows it to work.

root@bastion:~/bastion-proxy# mysql_config_editor print --all
[mysql]
user = remote
password = *****
host = mysql_local
[proxysql]
user = radminuser
password = *****
host = proxysql
port = 6032
[2 Apr 2018 10:00] MySQL Verification Team
Thank you for the feedback.

Thanks,
Umesh