我试图让GRANT ACCESS
成为MySQL服务器用户。
我在mybatch.bat
中写了以下命令:
@echo off
cd /
c:
set mysql_cmd = "GRANT ALL PRIVILEGES ON mydatabase.* TO 'myuser'@'192.168.1.%' IDENTIFIED BY '123abc' WITH GRANT OPTION;"
mysql --user=root --password=mysql --database=mysql -e %mysql_cmd%
pause
mybatch.bat
输出为:
mysql: option '-e' requires an argument
我做错了什么?
答案 0 :(得分:3)
这是有道理的,因为它只配置不需要运行数据库的设置。
->Creating a Service
->Creating/Modifying a my.ini file
->Configuring a Windows Firewall Exception
->Adding the install dir to the path Environment variable
然而。在实例启动并运行后,您可以使用mysql.exe命令行工具编写脚本:
usefollowing command
mysql.exe -u root -pm117988 -e "GRANT ALL ON *.* TO 'root'@'%' IDENTIFIED BY 'm117988' WITH GRANT OPTION; FLUSH PRIVILEGES;"
答案 1 :(得分:2)
用双引号包装%mysql_cmd%