我想创建一个新的数据库访问用户,但我需要在同一行传递整个命令:
mysql -u root; CREATE USER 'test' @ '%' IDENTIFIED BY '123456'; GRANT ALL PRIVILEGES ON *. * TO 'test' @ '%'; FLUSH PRIVILEGES;
我该如何让它发挥作用?
您可以使用echo命令,如:
echo "CREATE USER 'test' @ '%' IDENTIFIED BY '123456'; GRANT ALL PRIVILEGES ON *. * TO 'test' @ '%'; FLUSH PRIVILEGES; " | mysql -u root
或者使用-e
选项:
mysql -u root -e "CREATE USER 'test' @ '%' IDENTIFIED BY '123456'; GRANT ALL PRIVILEGES ON *. * TO 'test' @ '%'; FLUSH PRIVILEGES;"