AI写作智能体 自主规划任务,支持联网查询和网页读取,多模态高效创作各类分析报告、商业计划、营销方案、教学内容等。 广告
## 一、Ignoring query to other database 提示错误 在成功登录 mysql 后,输入任意一条命令都会出 `Ignoring query to other database ` 这条提示信息: ```sql mysql> show databases; Ignoring query to other database mysql> show databases; Ignoring query to other database mysql> show tables; Ignoring query to other database ``` ### 1.出现这条提示信息原因一般是因为登录时由于疏忽少了一个 `-u` 的参数: ```sql root@dawsson~:~# mysql -root -p Enter password: Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 63842 Server version: 5.7.25-0ubuntu0.16.04.2 (Ubuntu) ... ``` 退出后使用 `mysql -uroot -p` 重新登录即可。 ### 2.或者在登录时使用的大写的 `-U` 参数: ```sql root@dawsson~:~# mysql -Uroot -p Enter password: Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 63844 Server version: 5.7.25-0ubuntu0.16.04.2 (Ubuntu) ... mysql> show databases; Ignoring query to other database mysql> show tables; Ignoring query to other database ``` 大写 U 和小写 u 这两个参数的含义是不一样的。查看 mysql 的帮助: ```sql root@dawsson~:~# mysql --help| egrep 'user|safe-updates' -u, --user=name User for login if not current user. -U, --safe-updates Only allow UPDATE and DELETE that uses keys. -U, --i-am-a-dummy Synonym for option --safe-updates, -U. --select-limit=# Automatic limit for SELECT when using --safe-updates. --safe-updates. user (No default value) safe-updates FALSE root@dawsson~:~# ``` 可以发现,小写的 `-u` 用于正常的用户登录;大写的 `-U` 用于用户使用 **“安全更新”** 的身份登录,此时只能进行 update 和 delete 的操作,且必须加条件 where(其中 where 子句必须有索引列) 或 limit 才能执行。(前提是 数据库已开启安全更新的模式,即设置 `sql_safe_updates = 1`)