10.為了防止被惡意傳入非法參數(shù),例如where ID=234,別人卻輸入where ID=234 OR 1=1導(dǎo)致全部顯示,所以在web的表單中使用''或""來用字符串,在動(dòng)態(tài)URL中加入%22代表雙引號(hào)、%23代表井號(hào)、%27代表單引號(hào);傳遞未檢查過的值給mysql數(shù)據(jù)庫是非常危險(xiǎn)的;
22.啟動(dòng)mysqld服務(wù)進(jìn)程的安全選項(xiàng)開關(guān),--local-infile=0或1 若是0則客戶端程序就無法使用local load data了,賦權(quán)的一個(gè)例子grant insert(user) on mysql.user to 'user_name'@'host_name';若使用--skip-grant-tables系統(tǒng)將對任何用戶的訪問不做任何訪問控制,但可以用mysqladmin flush-privileges或mysqladmin reload來開啟訪問控制;默認(rèn)情況是show databases語句對所有用戶開放,可以用--skip-show-databases來關(guān)閉掉。
23.碰到Error 1045(28000) Access Denied for user 'root'@'localhost' (Using password:NO)錯(cuò)誤時(shí),你需要重新設(shè)置密碼,具體方法是:先用--skip-grant-tables參數(shù)啟動(dòng)mysqld,然后執(zhí)行mysql -u root mysql,mysql>update user set password=password('newpassword') where user='root';mysql>Flush privileges;,最后重新啟動(dòng)mysql就可以了。(文/fen)