0
点赞
收藏
分享

微信扫一扫

Linux别名设置导致mysql_config_editor配置登录报错

接手一台MySQL数据库后,使用mysql_config_editor创建了一个--login-path=mydba后,但是登录MySQL验证测试时一直报“mysql: [ERROR] unknown variable 'login-path=mydba'”这个错误。

测试过程中发现,使用绝对路径时正常(测试成功),但是如果不使用绝对路径的话, 就会报这个错误,如下所示:

使用相对路径测试报错:

$mysql --login-path=mydba
mysql: [ERROR] unknown variable 'login-path=mydba'

使用绝对路径测试OK:

$ /app/mysql/bin/mysql --login-path=mydba
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 1977670
Server version: 5.7.19-1-log Source distribution

Copyright (c) 2000, 2017, 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>

那么是什么原因导致的呢? 最后经过排查发现是因为 ~/.bashrc中设置了别名,从而导致这个错误出现, 如下所示(截取部分内容),原因:在shell的输入mysql --login-path=mydba命令后,它会转化成/app/mysql/bin/mysql -h localhost -u root -S /app/mysql/data/xxxx.sock -p --login-path=mydba ,这样--login-path=mydba就不是第一个参数了。所以就会报错。

$ more ~/.bashrc

# User specific aliases and functions
alias mysql='/app/mysql/bin/mysql -h localhost -u root -S /app/mysql/data/xxxx.sock -p'

取消别名后,问题解决。当然也可以直接使用绝对路径解决这个问题。所以如果你mysql_config_editor配置都正确的话,如果有一些很离奇的错误,不妨检查一下别名(alias)等设置。

举报

相关推荐

0 条评论