#!/bin/bash
#等号左右不能有空格
install_path=
mysql_root_user="root"
mysql_root_password=
mysql_host=
# 创建用户
function create_mysql_user(){
mysql -u${mysql_root_user} -p${mysql_root_password} -e "GRANT REPLICATION CLIENT, PROCESS ON *.* TO ${mysql_exporter_user}@'${mysql_host}' identified by '${mysql_exporter_password}';
GRANT SELECT ON performance_schema.* TO '${mysql_exporter_user}'@'${mysql_host}';" 2> /dev/null
}
create_mysql_user
参考:https://zhidao.baidu.com/question/878213827483738492.html
- 查看MySQL的所有用户命令
SELECT User FROM mysql.user
- 使用
2> /dev/null
的原因是有时连接时出现warning:
时可以忽略