需求描述:記錄一些不常用、而又好用的指令
指令:
登錄:mysql -u root -p
創(chuàng)建數(shù)據(jù)庫:create database djangostudy
創(chuàng)建用戶:create user ‘yeqinfang’@’%’ identified by ‘yeqinfang’;
查看密碼策略:show variables like “%validate%”;
臨時(shí)設(shè)置密碼策略(不同版本全局變量不一樣):
set global validate_password.length=6;
set global validate_password.policy=0;
給以用戶(包括自己)權(quán)限:grant all privileges on . to ‘yeqinfang’@’%’;
刷新權(quán)限:FLUSH PRIVILEGES;
更換密碼驗(yàn)證方式:ALTER USER ‘username’@’%’ IDENTIFIED WITH mysql_native_password BY ‘password’;
查看版本:select version();
查看端口:show global variables like ‘port’;
查看數(shù)據(jù)庫時(shí)區(qū):show variables like’%time_zone’;
設(shè)置時(shí)區(qū):set global time_zone = ‘+8:00’;
查看表結(jié)構(gòu):desc (tablename)