簡體   English   中英

Drupal網站中簡單查詢的SQL查詢錯誤

[英]SQL query error on simple queries in Drupal website

我們設置了一堆Drupal環境,並從中央服務器向它們發送命令。 從該服務器發送命令時,其格式如下-

drusha -v -d @website sql-query 'show tables;'

但是,我得到了錯誤-

ERROR 1064 (42000) at line 1: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '' at line 1

當我進入實際的數據庫服務器並手動運行命令時,它可以正常工作。

我試過切換報價並將其全部刪除,以及刪除;。 最后,但每次都會遇到相同的錯誤。 網站正在使用的數據庫信息正確。 使用此別名運行的任何其他命令都可以正常工作(刷新清除緩存等),因此我認為問題不在於實際的別名。

有誰知道為什么會這樣?

編輯-傳遞--database = databasename時,出現以下錯誤-

drusha -v -d @website sqlq -n "SHOW TABLES" --database=databasename

exception 'Drush\Sql\SqlException' with message 'Unable to find a    [error]
matching SQL Class. Drush cannot find your database connection
details.' in
phar:///usr/local/bin/drush/commands/sql/sql.drush.inc:588
Stack trace:
#0 phar:///usr/local/bin/drush/commands/sql/sql.drush.inc(426):
drush_sql_get_class(NULL)
#1 [internal function]: drush_sql_query('SHOW', 'TABLES')
#2 phar:///usr/local/bin/drush/includes/command.inc(366):
call_user_func_array('drush_sql_query', Array)
#3 phar:///usr/local/bin/drush/includes/command.inc(217):
_drush_invoke_hooks(Array, Array)
#4 [internal function]: drush_command('SHOW', 'TABLES')
#5 phar:///usr/local/bin/drush/includes/command.inc(185):
call_user_func_array('drush_command', Array)
#6 phar:///usr/local/bin/drush/lib/Drush/Boot/BaseBoot.php(67):
drush_dispatch(Array)
#7 phar:///usr/local/bin/drush/includes/preflight.inc(66):
Drush\Boot\BaseBoot->bootstrap_and_dispatch()
#8 phar:///usr/local/bin/drush/includes/startup.inc(325):
drush_main()
#9 phar:///usr/local/bin/drush/drush(114): drush_startup(Array)
#10 /usr/local/bin/drush(10): require('phar:///usr/loc...')

EDIT2-經過一些擺弄后,我通過將所有內容括在單引號和雙引號內,並切換了我運行的命令,使其與show table一起使用。 現在,這是我的命令-

ssh -q <webserverip> sudo -u apache /usr/local/bin/drush --root=/var/www/html/wwwroot/website/docroot/ sql-query "'UPDATE users SET mail='local@host' WHERE uid>1'"

我目前收到的錯誤是-

ERROR 1064 (42000) at line 1: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '@host WHERE uid>1' at line 1

謝謝。

您必須使用雙引號而不使用; 在settings.php所在文件夾中執行命令

drush -v -d  sql-query "show tables"

對於多站點drupal:

drush -v -d  sql-query "show tables" --database=websitedbname

要么

drush -v -d  sql-query "show tables" --target=website

https://drushcommands.com/drush-7x/sql/sql-query/

另外,您可以手動連接到數據庫(mysql或其他數據庫)並發出請求。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM