更新時間:2020-08-13 11:38:35 來源:動力節點 瀏覽1291次
MySQL數據庫教程常用命令有哪些?這個問題就由動力節點java培訓機構的小編來告訴大家。
1、MySQL常用命令
create database name; 創建數據庫
use databasename; 選擇數據庫
drop database name 直接刪除數據庫,不提醒
show tables; 顯示表
describe tablename; 表的詳細描述
select 中加上distinct去除重復字段
mysqladmin drop database name 刪除數據庫前,有提示。
顯示當前mysql版本和當前日期
select version(),current_date;
2、修改mysql中root的密碼:
shell>mysql -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表的列信息);
3、grant
創建一個可以從任何地方連接服務器的一個完全的超級用戶,但是必須使用一個口令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;
動力節點官網有MySQL數據庫教程的文檔可以進行在線學習,感興趣的小伙伴可以去看看哦。
以上就是動力節點java培訓機構的小編針對“MySQL數據庫教程之常用命令”的內容進行的回答,希望對大家有所幫助,如有疑問,請在線咨詢,有專業老師隨時為你服務。
0基礎 0學費 15天面授
有基礎 直達就業
業余時間 高薪轉行
工作1~3年,加薪神器
工作3~5年,晉升架構
提交申請后,顧問老師會電話與您溝通安排學習