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

首頁(yè) > 數(shù)據(jù)庫(kù) > MySQL > 正文

Linux操作系統(tǒng)操作MySQL常用命令小結(jié)

2024-07-24 13:13:57
字體:
來(lái)源:轉(zhuǎn)載
供稿:網(wǎng)友

下面給大家分享mysql常用命令,

 -- 啟動(dòng)數(shù)據(jù)庫(kù)service myslqd start;-- 進(jìn)入MySQL -u root -p/mysql -h localhost -u root -p DatabaseName;-- 列出數(shù)據(jù)庫(kù)show database;-- 創(chuàng)建數(shù)據(jù)庫(kù)create database XXXX;-- 選擇數(shù)據(jù)庫(kù)use DatabaseName;-- 羅列表show table;-- 顯示表格的屬性show columns from tablename;-- 建立數(shù)據(jù)庫(kù)source filename.txt;-- 增加一個(gè)字段alter table tablename add column filename datatype;-- 增加多個(gè)字段alter table tablename add column filename1 datatype,add column filename2 datatype;-- 新增一個(gè)用戶grant all On *.* to user@localhost identity by "password";-- 查詢時(shí)間select now();-- 查詢用戶select user();-- 查詢數(shù)據(jù)庫(kù)版本select version();-- 查詢當(dāng)前使用的數(shù)據(jù)庫(kù)select database();-- 刪除student_course數(shù)據(jù)庫(kù)中的student數(shù)據(jù)便rm -f student_cource/student.*-- 備份數(shù)據(jù)庫(kù)(備份數(shù)據(jù)庫(kù)Apple1)MySQLdump -u root -p Apple1>C:/Apple1.txt-- 備份表(將數(shù)據(jù)庫(kù)Apple1中的mytable表備份)MySQLdump -u root -p mytable>C:/Apple.txt-- 創(chuàng)建臨時(shí)表(mytable)create temporary table mytable(id int,address varchar(20),name varchar(20));-- 創(chuàng)建表前先判斷系統(tǒng)是否存在這個(gè)表create table if not exists mytable(......);-- 從已有的table1表中復(fù)制表結(jié)構(gòu)到table2create table table2 select * from table1 where 1<>1;-- 復(fù)制表create table table2 select * from table1;-- 重命名表名alter table table1 rename as table2;-- 修改列的數(shù)據(jù)類型alter table table1 modify ID int unsigned;--把列ID的類型修改為int unsignedalter table table1 change ID SID int unsigned; --把列ID改名為 SID且類型改為int unsigned-- 創(chuàng)建索引alter table table1 add index Ind_id (ID);create index ind_ID on tablename (ID);create unique index ind_id on tablename(ID);-- 刪除索引drop index ind_id On table1;alter table table1 drop index ind_ID;-- 聯(lián)合查詢字符與多個(gè)列連接‘select concat(ID,':',name,'=') from table1-----------------------第二片--------------------------------------顯示數(shù)據(jù)庫(kù)show database;--顯示數(shù)據(jù)庫(kù)中的表show tables;--顯示數(shù)據(jù)表結(jié)構(gòu)describe tablename;--顯示表記錄select * from tablename;--查詢能操作MySQL的用戶select * from user;--創(chuàng)建數(shù)據(jù)庫(kù)create database databasename--例如↓MySQL> create database AA;---創(chuàng)建表user AA;mysql> create table table1(ID int auto_increment not null primary key,name char(6),sex char(6),birthday date) ---插入幾條記錄 MySQL> insert into AA values('','張三','男','1971-10-01'); MySQL> insert into AA values('','劉佳佳','女','1978-10-01'); --驗(yàn)證結(jié)果 MySQL> select * from AA;--修改張三的生日為1971-01-10MySQL> update AA set birthday = '1971-01-10' where ID = '1'; --刪除記錄MySQL> delete from AA where ID = '1';--刪除表以及庫(kù)mysql> drop table tablename;MySQL> drop database databasename;--新增萬(wàn)能用戶-- 格式:grant select On database.* to username@localhost identity by 'password'用戶名user_1 密碼是123456--可以自任何PC上登錄這個(gè)用戶對(duì)數(shù)據(jù)庫(kù)為所欲為MySQL> grant select,insert update,delete on *.* to user_1@"%" identity by "123456";--創(chuàng)建只有在本機(jī)才能操作數(shù)據(jù)庫(kù)的用戶用戶名user_2 密碼是123456MySQL> grant select,insert update,delete on *.* to user_2@localhost identity by "123456";--登錄數(shù)據(jù)庫(kù)庫(kù)MySQL> -u user_1 -p -h IP地址;

以上所述是小編給大家介紹的Linux操作系統(tǒng)操作MySQL常用命令小結(jié),希望對(duì)大家有所幫助,如果大家有任何疑問(wèn)請(qǐng)給我留言,小編會(huì)及時(shí)回復(fù)大家的。在此也非常感謝大家對(duì)VeVb武林網(wǎng)網(wǎng)站的支持!


注:相關(guān)教程知識(shí)閱讀請(qǐng)移步到MYSQL教程頻道。
發(fā)表評(píng)論 共有條評(píng)論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 桐城市| 海晏县| 昭通市| 蕉岭县| 三都| 崇文区| 阳春市| 米林县| 商水县| 资中县| 平阳县| 嵩明县| 南郑县| 永济市| 林周县| 黄梅县| 于都县| 信宜市| 安西县| 汪清县| 渭南市| 来宾市| 新和县| 柞水县| 龙里县| 珲春市| 平度市| 高唐县| 湄潭县| 延安市| 南丰县| 乐至县| 哈密市| 绍兴市| 东乡县| 偃师市| 湘阴县| 江源县| 侯马市| 永川市| 凤城市|