Linux别名设置导致mysql_config_editor配置登录报错
2023-09-11 14:13:57 时间
接手一台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)等设置。
相关文章
- Linux中数据库的安装和配置(MySQL与Maria DB)
- Linux中数据库的安装和配置(MySQL与Maria DB)
- MySQL Binlog Digger 4.28 【mysql日志分析工具】
- Linux rpm包安装MySQL数据库问题总结
- centos7 安装 mysql(在线安装)
- [小白技巧]如何在Linux上检查MySQL数据表的存储引擎类型
- MySQL 5.7.14安装说明,解决服务无法启动
- Linux 服务器安装Mysql 5.7版本
- mysql实现主从复制/主从同步
- Mysql的安全配置向导命令mysql_secure_installation
- MySQL 加锁处理分析 ---非常牛逼
- MySQL 调优基础(二) Linux内存管理
- Linux安装Mysql,Centos7安装Mysql5.5,Linux Mysql安装
- mac ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)
- Linux下Mysql的odbc配置
- MYSQL 主从复制---简单易学
- Mysql_mysql force Index 强制索引
- Linux下的Mysql的远程访问
- java(2014)实现对mysql数据库分页的代码
- linux 怎么完全卸载mysql数据库
- (0.2)linux下Mysql的安装配置与管理入门(目录篇)
- Mysql中出现please use mysql_upgrade to fix this errot解决的办法
- 【Linux】linux中删除指定日期之前的文件
- MySQL数据库InnoDB存储引擎中的锁机制--转载
- mysql的DATE_FORMAT用法
- 【MySql 】is not allowed to connect to this MySql server 无法访问远程MySQL数据库