MySQL命令行小贴士

MySQL命令行小贴士

创建用户和数据库

#/bin/bash
mysql -u root -p -e "CREATE DATABASE $1 CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci; USE $1; CREATE USER '$1'@'%' IDENTIFIED BY '$2'; GRANT ALL PRIVILEGES ON $1.* TO '$1'@'%'; FLUSH PRIVILEGES;"