2

我试图让GRANT ACCESSMySQL 服务器用户。

我写了以下命令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

我究竟做错了什么?

4

2 回答 2

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;"
于 2013-06-12T14:20:38.493 回答
2

%mysql_cmd%双引号括起来

于 2013-06-12T14:15:34.817 回答