作者:彭润昕_149 | 来源:互联网 | 2024-11-02 15:19
在尝试使用指定的数据库进行登录时,遇到了权限问题。具体表现为用户'lzldb'@'%'无权访问数据库'lzldb',错误代码为1044(42000)。命令行参数`-D`指定了数据库名称,但未能成功连接。建议检查用户的权限配置,确保其具有对目标数据库的访问权限。此外,使用密码时应谨慎处理,避免在命令行中明文显示。
-D指定db登陆失败
#mysql -ulzl -p123456 -Dlzldb --socket=/my3456/mysql.sock
Warning: Using a password on the command line interface can be insecure.
ERROR 1044 (42000): Access denied for user 'lzldb'@'%' to database 'lzldb'
困扰了很久,查了user没有问题。
原因很简单 -D参数要加到后面
#mysql -ulzl -p123456 --socket=/my3456/mysql.sock -Dlzldb
Warning: Using a password on the command line interface can be insecure.
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 200389
Server version: 5.7.26-log Source distribution
Copyright (c) 2000, 2014, 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> select database();
+--------------+
| database() |
+--------------+
| lzldb |
+--------------+
1 row in set (0.00 sec)
总结我已知的mysq参数问题:
1 mysql命令参数还是很敏感的,还是要注意参数顺序
2 -D参数尽量靠后
3 --defaults-file必须放在第一个参数