MySQL-02:“数据库”操作基本命令及权限笔记
生活随笔
收集整理的這篇文章主要介紹了
MySQL-02:“数据库”操作基本命令及权限笔记
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
目錄
?
數據庫操作
1、顯示數據庫
2、創建數據庫
3、使用數據庫
4、用戶管理
5、授權管理
數據庫操作
1、顯示數據庫
SHOW DATABASES;默認數據庫:
mysql - 用戶權限相關數據
test - 用于用戶測試數據
information_schema - MySQL本身架構相關數據
2、創建數據庫
# utf-8 CREATE DATABASE 數據庫名稱 DEFAULT CHARSET utf8 COLLATE utf8_general_ci; CREATE DATABASE 數據庫名稱 DEFAULT CHARSET utf8;# gbk CREATE DATABASE 數據庫名稱 DEFAULT CHARACTER SET gbk COLLATE gbk_chinese_ci;3、使用數據庫
USE db_name;如要顯示當前使用的數據庫中所有表:SHOW TABLES;
4、用戶管理
創建用戶create user?'用戶名'@'IP地址'?identified by?'密碼'; 刪除用戶drop user?'用戶名'@'IP地址'; 修改用戶rename user?'用戶名'@'IP地址'; to?'新用戶名'@'IP地址';; 修改密碼set password?for?'用戶名'@'IP地址'?= Password('新密碼')PS:用戶權限相關數據保存在mysql數據庫的user表中,所以也可以直接對其進行操作(不建議) 用戶名@IP地址 用戶只能在改IP下才能訪問 用戶名@192.168.1.% 用戶只能在改IP段下才能訪問(通配符%表示任意) 用戶名@% 用戶可以再任意IP下訪問(默認IP地址為%)5、授權管理
show grants?for?'用戶'@'IP地址'??????????????????-- 查看權限 grant? 權限 on 數據庫.表 to???'用戶'@'IP地址'??????-- 授權 revoke 權限 on 數據庫.表 from?'用戶'@'IP地址'??????-- 取消權限 all privileges 除grant外的所有權限select 僅查權限select,insert 查和插入權限...usage 無訪問權限alter 使用alter tablealter routine 使用alter procedure和drop procedurecreate 使用create tablecreate routine 使用create procedurecreate temporary tables 使用create temporary tablescreate user 使用create user、drop user、rename user和revoke all privilegescreate view 使用create viewdelete 使用deletedrop 使用drop tableexecute 使用call和存儲過程file 使用select into outfile 和 load data infilegrant option 使用grant 和 revokeindex 使用indexinsert 使用insertlock tables 使用lock tableprocess 使用show full processlistselect 使用selectshow databases 使用show databasesshow view 使用show viewupdate 使用updatereload 使用flushshutdown 使用mysqladmin shutdown(關閉MySQL)super 使用change master、kill、logs、purge、master和set global。還允許mysqladmin????調試登陸replication client 服務器位置的訪問replication slave 由復制從屬使用授權內部
grant all privileges on db1.tb1 TO '用戶名'@'IP'grant select on db1.* TO '用戶名'@'IP'grant select,insert on *.* TO '用戶名'@'IP'revoke select on db1.tb1 from '用戶名'@'IP' 對于目標數據庫以及內部其他:數據庫名.* 數據庫中的所有數據庫名.表 指定數據庫中的某張表數據庫名.存儲過程 指定數據庫中的存儲過程*.* 所有數據庫其他
# 啟動免授權服務端 mysqld --skip-grant-tables# 客戶端 mysql -u root -p# 修改用戶名密碼 update mysql.user set authentication_string=password('666') where user='root'; flush privileges;摘抄自:https://www.cnblogs.com/wupeiqi/articles/5713315.html
?
?
?
?
?
?
?
總結
以上是生活随笔為你收集整理的MySQL-02:“数据库”操作基本命令及权限笔记的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: MySQL-01:下载安装配置及初始化命
- 下一篇: MySQL-03:数据表操作基本命令笔记