我面临一个让我发疯的问题,我一直在寻找解决方案,但我对 php 的有限知识不足以解决它,所以我们开始吧,希望你能帮助我。
我正在通过 PHP 生成一个查询,该查询如下:
CREATE USER 'wally'@'localhost' IDENTIFIED BY 'wally123';
GRANT USAGE ON * . * TO 'wally'@'localhost' IDENTIFIED BY 'wally123' WITH MAX_QUERIES_PER_HOUR 0 MAX_CONNECTIONS_PER_HOUR 0 MAX_UPDATES_PER_HOUR 0 MAX_USER_CONNECTIONS 0 ;
GRANT ALL PRIVILEGES ON `wally\_%` . * TO 'wally'@'localhost';
CREATE USER 'wally'@'%' IDENTIFIED BY 'wally123'; GRANT USAGE ON * . * TO 'wally'@'%' IDENTIFIED BY 'wally123' WITH MAX_QUERIES_PER_HOUR 0 MAX_CONNECTIONS_PER_HOUR 0 MAX_UPDATES_PER_HOUR 0 MAX_USER_CONNECTIONS 0 ;
GRANT ALL PRIVILEGES ON `wally\_%` . * TO 'wally'@'%';
CREATE DATABASE wally_foro;
CREATE DATABASE wally_foro2;
当我在我的 phpmyadmin 上运行它时,它可以完美运行,但是当我将此查询输入 ssh 命令并发送它时:
mysql -uMYUSERHERE -pMYPASSWORDHERE -e "CREATE USER 'wally'@'localhost' IDENTIFIED BY 'wally123'; GRANT USAGE ON * . * TO 'wally'@'localhost' IDENTIFIED BY 'wally123' WITH MAX_QUERIES_PER_HOUR 0 MAX_CONNECTIONS_PER_HOUR 0 MAX_UPDATES_PER_HOUR 0 MAX_USER_CONNECTIONS 0 ; GRANT ALL PRIVILEGES ON `wally\_%` . * TO 'wally'@'localhost'; CREATE USER 'wally'@'%' IDENTIFIED BY 'wally123'; GRANT USAGE ON * . * TO 'wally'@'%' IDENTIFIED BY 'wally123' WITH MAX_QUERIES_PER_HOUR 0 MAX_CONNECTIONS_PER_HOUR 0 MAX_UPDATES_PER_HOUR 0 MAX_USER_CONNECTIONS 0 ; GRANT ALL PRIVILEGES ON `wally\_%` . * TO 'wally'@'%'; CREATE DATABASE wally_foro; CREATE DATABASE wally_foro2;"
它只是给了我一个错误:
第 1 行的 ERROR 1064 (42000):您的 SQL 语法有错误;检查与您的 MySQL 服务器版本相对应的手册,以在第 1 行的“TO 'wally'@'localhost'' 附近使用正确的语法*
我需要它是一个 ssh 连接,但我不知道如何使它工作。如果假设我不能直接在命令行上使用脚本,为什么它会通过 line 命令而不是在 phpmyadmin 中退出错误。我错了吗 ?
谢谢你,真的很感谢你的支持!
感谢您的支持。到目前为止,我得到了这个:
mysql -uMYUSER -pMYPASS -e "CREATE DATABASE wally_foro; CREATE DATABASE wally_foro2; CREATE USER 'wally'@'localhost' IDENTIFIED BY 'wally123'; GRANT USAGE ON * . * TO 'wally'@'localhost' IDENTIFIED BY 'wally123' WITH MAX_QUERIES_PER_HOUR 0 MAX_CONNECTIONS_PER_HOUR 0 MAX_UPDATES_PER_HOUR 0 MAX_USER_CONNECTIONS 0 ; GRANT ALL PRIVILEGES ON ``wally\\\_\%`` . * TO 'wally'@'localhost'; CREATE USER 'wally'@'\%' IDENTIFIED BY 'wally123'; GRANT USAGE ON * . * TO 'wally'@'\%' IDENTIFIED BY 'wally123' WITH MAX_QUERIES_PER_HOUR 0 MAX_CONNECTIONS_PER_HOUR 0 MAX_UPDATES_PER_HOUR 0 MAX_USER_CONNECTIONS 0 ; GRANT ALL PRIVILEGES ON ``wally\\\_\%`` . * TO 'wally'@'\%'; "
现在它确实创建了 localhost 用户和数据库,但不是我认为可能涉及符号 % 的外部用户,我试图对其进行 scape 并复制它,但仍然无法正常工作。
谢谢 !