Windows下操作MySQL
啟動關閉服務:
用管理員用戶身份啟動cmd.exe
關閉:net stop mysql
啟動:net start mysql
用密碼登錄MySQL:mysql -u root -p
顯示數據庫實例:show databases;
選擇數據庫實例:use test;
顯示實例下表信息:show tables;
查詢表信息:select * from users;
設定編碼:charset gbk;
查看表詳情:desc users;
創建索引:create index users_name on users(name);
查看表索引:show index from users;
創建組合索引:create index users_userId_username_sex on users(userId, username, sex);
查看索引是否生效:explain select * from users where username='xp' and sex='男'; //key列如果為NULL,則沒有使用索引
explain 列的解釋參考:https://blog.csdn.net/qq_33774822/article/details/61197420
索引失效的情況:用 in 、not in 、like '%A' 、or (測試發現即使or的列上都有索引,索引也不生效,但是or的列是主鍵時索引生效)

浙公網安備 33010602011771號