linux 创建mysql用户以及同名数据库并授权的shell脚本
#!/bin/bash

username="wp_$1"
password=$2

mysql -uroot -e "CREATE USER '${username}'@'%' IDENTIFIED BY '${password}'"

mysql -uroot -e "CREATE DATABASE IF NOT EXISTS ${username}"

mysql -uroot -e "GRANT ALL PRIVILEGES ON ${username}.* TO ${username}@'%'"

mysql -uroot -e "FLUSH PRIVILEGES"

 

以上命令中省略了 -p部分。为了安全在mysql配置文件中[client]下配置user和password即可。

  • 当前日期:
  • 北京时间:
  • 时间戳:
  • 今年的第:18周
  • 我的 IP:13.58.216.183
农历
五行
冲煞
彭祖
方位
吉神
凶神
极简任务管理 help
+ 0 0 0
Task Idea Collect