MySQl 错误 1046 与优化表的 cron
按照我之前的问题之一,我开始遇到解决方案错误:
ERROR 1046 (3D000) at line 1: No database selected
具有执行权限的 Crong Job db-optimize.sh。
#!/bin/bash
chk="select concat(TABLE_SCHEMA,'.', TABLE_NAME) from information_schema.tables where data_free>0;"
for tbl in $(mysql -u root -ppass -N <<< $chk)
do
mysql -u root -ppass -N <<< "optimize table $tbl"
done
我查了一下错误代码,它说我需要处于“MySQL”模式。尽管这看起来是代码已经在做的事情。
Following one of my previous questions I have started to get a error with the solution:
ERROR 1046 (3D000) at line 1: No database selected
Crong Job db-optimize.sh with execute permissions.
#!/bin/bash
chk="select concat(TABLE_SCHEMA,'.', TABLE_NAME) from information_schema.tables where data_free>0;"
for tbl in $(mysql -u root -ppass -N <<< $chk)
do
mysql -u root -ppass -N <<< "optimize table $tbl"
done
I have looked up the error code and it says that I need to be in "MySQL" mode. Although this looks to be what the code is already doing.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这个问题是由于没有转义表名引起的,因为我有一个名为“show”的表
This problem was being caused by not escaping the table name and because I had a table called "show"