mysql-批量命令

单独执行

mysql -uroot -p -e 'SELECT user,host,authentication_string FROM mysql.user' 
mysql -uroot -p -e 'SELECT USER()'
mysql -uroot -p -e 'SELECT VERSION()'

批量执行

tee /tmp/test.sql << EOF
# 查询账户密码
SELECT user,host,authentication_string FROM mysql.user;
# 当前用户
SELECT USER();
# 当前数据库
SELECT DATABASE();
# 当前版本
SELECT VERSION();
EOF
mysql -uroot -p  < /tmp/test.sql
posted @ 2022-03-21 20:21  自动侠  阅读(79)  评论(0编辑  收藏  举报