Linux别名设置导致mysql_config_editor配置登录报错
2022-10-17 22:40 潇湘隐者 阅读(168) 评论(0) 编辑 收藏 举报接手一台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)等设置。

【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】凌霞软件回馈社区,博客园 & 1Panel & Halo 联合会员上线
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】博客园社区专享云产品让利特惠,阿里云新客6.5折上折
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 微软正式发布.NET 10 Preview 1:开启下一代开发框架新篇章
· 没有源码,如何修改代码逻辑?
· PowerShell开发游戏 · 打蜜蜂
· 在鹅厂做java开发是什么体验
· WPF到Web的无缝过渡:英雄联盟客户端的OpenSilver迁移实战
2018-10-17 SQL Server 更新统计信息出现严重错误,应放弃任何可能产生的结果
2018-10-17 SQL Server中LIKE %search_string% 走索引查找(Index Seek)浅析
2016-10-17 Cannot execute as the database principal because the principal "guest" does not exist, this type of principal cannot be impersonated, or you do not have permission.
2013-10-17 The process could not execute 'sp_repldone/sp_replcounters' on 'ServerName'