exec('mysql --execute "GRANT ALL PRIVILEGES ON database.* TO 'user'@'122.169.XXX.XX' IDENTIFIED BY 'password'"');
但它发出错误!!
Parse error: syntax error, unexpected T_STRING
应保留格式,因为它需要与在shell中执行
的方式相同答案 0 :(得分:6)
你必须逃避'
:
exec('mysql --execute "GRANT ALL PRIVILEGES ON database.* TO \'user\'@\'122.169.XXX.XX\' IDENTIFIED BY \'password\'"');
答案 1 :(得分:1)
您正在使用单引号启动您的php字符串。在查询过程中,您将使用单引号将其停止。你需要逃脱它们。
exec('mysql --execute "GRANT ALL PRIVILEGES ON database.* TO \'user<'@<'122.169.XXX.XX<' IDENTIFIED BY \'password\'"');
答案 2 :(得分:0)
您需要使用.
来连接字符串。
该行应为:
exec('mysql --execute " GRANT ALL PRIVILEGES ON database.* TO ' . user. '@ 122.169.XXX.XX IDENTIFIED BY ' . password . '"');
答案 3 :(得分:0)
您需要转义字符串:
exec('mysql --execute "GRANT ALL PRIVILEGES ON database.* TO \'user\'@\'122.169.XXX.XX\' IDENTIFIED BY \'password\'"');
有关详情,请参阅:http://www.php.net/manual/en/language.types.string.php
答案 4 :(得分:0)
您需要转义字符串:
转义:
exec('mysql --execute "GRANT ALL PRIVILEGES ON database.* TO \'user\'@\'122.169.XXX.XX\' IDENTIFIED BY \'password\'"');