【網絡安全實驗】解決 ERROR 1064 (42000): You have an error in your SQL syntax ... near …

背景

今天做網絡安全的時候,遇到了這個錯誤,這個問題之前遇到過幾次,但是總是會因爲疏忽又相遇,今天把這個問題寫出來,加深印象吧。

任務

操作4:聯合查詢猜字段數

聯合查詢字段數量不同:select user,password from users union select
user,password  from mysql.user;
猜前面的查詢字段數
select user,first_name,password from users union select 1;
select user,first_name,password from users union select 1,2;
....

報錯如下:

select user,password from users union select user,password  from mysql.user;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ':select user,first_name,password from users union select user,password  from ' at line 1

解決

其實這個問題就是語法上的錯誤,在MySQL中,爲了區分MySQL的關鍵字與普通字符,MySQL引入了一個反引號。

詳情見:傳送門

反引號不知道在哪?(快看下面這張圖吧…)

select `user`,`password` from users union select `user`,`password`  from mysql.user;

再次運行就不會報錯了

學如逆水行舟,不進則退
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章