国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 數據庫 > MySQL > 正文

Mysql常用命令 詳細整理版

2024-07-24 12:54:20
字體:
來源:轉載
供稿:網友
Mysql常用命令
  show databases; 顯示數據庫
  create database name; 創建數據庫
  use databasename; 選擇數據庫
  drop database name 直接刪除數據庫,不提醒
  show tables; 顯示表
  describe tablename; 顯示具體的表結構
  select 中加上distinct去除重復字段
  mysqladmin drop databasename 刪除數據庫前,有提示。
  顯示當前mysql版本和當前日期
  select version(),current_date;
  修改mysql中root的密碼:
  shell>mysql -h localhost -u root -p //登錄
  mysql> update user set password=password("xueok654123") where user='root';
  mysql> flush privileges //刷新數據庫
  mysql>use dbname; 打開數據庫:
  mysql>show databases; 顯示所有數據庫
  mysql>show tables; 顯示數據庫mysql中所有的表:先use mysql;然后
  mysql>describe user; 顯示表mysql數據庫中user表的列信息);
  grant
  創建用戶firstdb(密碼firstdb)和數據庫,并賦予權限于firstdb數據庫
  mysql> create database firstdb;
  mysql> grant all on firstdb.* to firstdb identified by 'firstdb'
  會自動創建用戶firstdb
  mysql默認的是本地主機是localhost,對應的IP地址就是127.0.0.1,所以你用你的IP地址登錄會出錯,如果你想用你的IP地址登錄就要先進行授權用grant命令。
  mysql>grant all on *.* to root@202.116.39.2 identified by "123456";
  說明:grant 與on 之間是各種權限,例如:insert,select,update等
  on 之后是數據庫名和表名,第一個*表示所有的數據庫,第二個*表示所有的表
  root可以改成你的用戶名,@后可以跟域名或IP地址,identified by 后面的是登錄用的密碼,可以省略,即缺省密碼或者叫空密碼。
  drop database firstdb;
  創建一個可以從任何地方連接服務器的一個完全的超級用戶,但是必須使用一個口令something做這個
  mysql> grant all privileges on *.* to user@localhost identified by 'something' with
  增加新用戶
  格式:grant select on 數據庫.* to 用戶名@登錄主機 identified by "密碼"
  GRANT ALL PRIVILEGES ON *.* TO monty@localhost IDENTIFIED BY 'something' WITH GRANT OPTION;
  GRANT ALL PRIVILEGES ON *.* TO monty@"%" IDENTIFIED BY 'something' WITH GRANT OPTION;
  刪除授權:
  mysql> revoke all privileges on *.* from root@"%";
  mysql> delete from user where user="root" and host="%";
  mysql> flush privileges;
  創建一個用戶custom在特定客戶端it363.com登錄,可訪問特定數據庫fangchandb
  mysql >grant select, insert, update, delete, create,drop on fangchandb.* to custom@ it363.com identified by ' passwd'
  重命名表:
  mysql > alter table t1 rename t2;
  mysqldump
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 孝昌县| 田阳县| 泾阳县| 盐津县| 汪清县| 桂林市| 嘉义市| 会宁县| 巧家县| 东乡族自治县| 兴义市| 贵溪市| 沅江市| 芷江| 肃北| 榆树市| 舞阳县| 竹溪县| 神木县| 宜宾市| 马关县| 潮安县| 武平县| 南京市| 乡城县| 保山市| 瑞丽市| 白银市| 延庆县| 随州市| 望谟县| 铜川市| 怀柔区| 东乡族自治县| 靖宇县| 临澧县| 新蔡县| 且末县| 碌曲县| 海安县| 原平市|