国产成人精品亚洲777人妖,欧美日韩精品一区视频,最新亚洲国产,国产乱码精品一区二区亚洲

您的位置:首頁技術(shù)文章
文章詳情頁

MySQL常用命令及操作

瀏覽:8日期:2023-10-17 10:32:02

1、登錄與退出 1)登錄windows下直接在DOS命令窗口用root用戶登錄輸入mysql回車;linux下輸入使用PUTTY連接mysql的服務(wù)器,然后輸入: mysql -u 用戶名 -p 密碼 即可進(jìn)入mysql>界面。 2)退出執(zhí)行 exit 回車 即可。 3)修改密碼mysql -u 用戶名 -p 密碼 password 新密碼

2、數(shù)據(jù)庫基本操作 1)顯示數(shù)據(jù)庫mysql>show databases; 2)創(chuàng)建數(shù)據(jù)庫mysql>create database name; //這里的name是指需要?jiǎng)?chuàng)建的數(shù)據(jù)庫的名字。 3)刪除數(shù)據(jù)庫mysql>drop database name; //這里的name是指需要?jiǎng)h除的數(shù)據(jù)庫的名字。 4)選擇數(shù)據(jù)庫mysql>use databasename; //這里的databasename是指選擇的數(shù)據(jù)庫的名字。 5)查看當(dāng)前使用的數(shù)據(jù)庫mysql>select database();

3、表的基本操作 注意:表的所有操作之前必須使用use databasename;說明選擇的哪個(gè)數(shù)據(jù)庫。 1)顯示表mysql>show tables; 2)顯示具體的表結(jié)構(gòu)mysql>describe tablename; 3)創(chuàng)建表mysql>create table tablename(col1 type, col2 type....); //這里的tablename是指要?jiǎng)?chuàng)建的表名。 4)刪除表mysql>drop table tablename; //這里的tablename是指要?jiǎng)?chuàng)建的表名。 5)插入數(shù)據(jù)insert into tablename values(col1 value,col2 value....); 6)查詢數(shù)據(jù)select * from tablename where .......; 7)更新數(shù)據(jù)update tablename set col1 = newvalue where .....; 8)刪除數(shù)據(jù)delete from tablename where ......;

4、文件導(dǎo)入 1)導(dǎo)入.sql文件命令(例如D:/mysql.sql)mysql>use databasename;mysql>source d:/mysql.sql; 2)用文本方式將數(shù)據(jù)導(dǎo)入數(shù)據(jù)庫表mysql>load data local infile 'filename' into table tablename;

5、用戶權(quán)限操作 1)增加新用戶grant select on databasename.* to username@localhost identified by 'password' 2)增加所有權(quán)限給用戶grant all privileges on *.* to username@localhost identified by 'password'; 3)增加數(shù)據(jù)庫的具體操作給用戶grant select ,insert,update on databasename.* to username@localhost identified by 'password' 4)增加數(shù)據(jù)庫的某張表的操作權(quán)限給用戶grant update,delete on databasename.tablename to username@localhost identified by 'password' 5)刪除權(quán)限r(nóng)evoke all privileges on *.* from username@localhost 6)flush privileges;

6、MySQL數(shù)據(jù)庫備份遷移 1)遠(yuǎn)程數(shù)據(jù)庫備份mysqldump -h 10.201.10.243 -udiscuz -p discuz >discuz_69.sql 2)導(dǎo)入備份的數(shù)據(jù)庫=> mysql -ushenweiyan -p //登錄MySQLEnter password:mysql> use newucdb;mysql> source /home/shenweiyan/mysql-bk/discuzdb_3_2.sql; //將discuz數(shù)據(jù)庫信息導(dǎo)入成為newucdb的保存信息

標(biāo)簽: MySQL 數(shù)據(jù)庫
相關(guān)文章:
主站蜘蛛池模板: 海原县| 达拉特旗| 石嘴山市| 来安县| 宿州市| 鹿泉市| 武鸣县| 乌兰浩特市| 绵竹市| 梨树县| 菏泽市| 正宁县| 安吉县| 临潭县| 鄂托克前旗| 临潭县| 淳化县| 松桃| 承德县| 桦川县| 榆中县| 玛纳斯县| 西吉县| 稻城县| 章丘市| 寿宁县| 迭部县| 庆安县| 旬阳县| 左云县| 永吉县| 仪征市| 祁东县| 车险| 繁峙县| 阿荣旗| 津市市| 铜梁县| 建始县| 大冶市| 临朐县|