更新時間:2020-08-13 11:38:35 來源:動力節(jié)點(diǎn) 瀏覽1631次
MySQL數(shù)據(jù)庫教程常用命令有哪些?這個問題就由動力節(jié)點(diǎn)java培訓(xùn)機(jī)構(gòu)的小編來告訴大家。

1、MySQL常用命令
create database name; 創(chuàng)建數(shù)據(jù)庫
use databasename; 選擇數(shù)據(jù)庫
drop database name 直接刪除數(shù)據(jù)庫,不提醒
show tables; 顯示表
describe tablename; 表的詳細(xì)描述
select 中加上distinct去除重復(fù)字段
mysqladmin drop database name 刪除數(shù)據(jù)庫前,有提示。
顯示當(dāng)前mysql版本和當(dāng)前日期
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 //刷新數(shù)據(jù)庫
mysql>use dbname; 打開數(shù)據(jù)庫:
mysql>show databases; 顯示所有數(shù)據(jù)庫
mysql>show tables; 顯示數(shù)據(jù)庫mysql中所有的表:先use mysql;然后
mysql>describe user; 顯示表mysql數(shù)據(jù)庫中user表的列信息);
3、grant
創(chuàng)建一個可以從任何地方連接服務(wù)器的一個完全的超級用戶,但是必須使用一個口令something做這個
mysql> grant all privileges on *.* to user@localhost identified by ’something’ with
增加新用戶
格式:grant select on 數(shù)據(jù)庫.* to 用戶名@登錄主機(jī) 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;
刪除授權(quán):
mysql> revoke all privileges on *.* from root@”%”;
mysql> delete from user where user=”root” and host=”%”;
mysql> flush privileges;
創(chuàng)建一個用戶custom在特定客戶端it363.com登錄,可訪問特定數(shù)據(jù)庫fangchandb
mysql >grant select, insert, update, delete, create,drop on fangchandb.* to custom@ it363.com identified by ‘ passwd’
重命名表:
mysql > alter table t1 rename t2;
動力節(jié)點(diǎn)官網(wǎng)有MySQL數(shù)據(jù)庫教程的文檔可以進(jìn)行在線學(xué)習(xí),感興趣的小伙伴可以去看看哦。

以上就是動力節(jié)點(diǎn)java培訓(xùn)機(jī)構(gòu)的小編針對“MySQL數(shù)據(jù)庫教程之常用命令”的內(nèi)容進(jìn)行的回答,希望對大家有所幫助,如有疑問,請在線咨詢,有專業(yè)老師隨時為你服務(wù)。

初級 202925

初級 203221

初級 202629

初級 203743