標(biāo)題: linux mysql 操作知識 [打印本頁] 作者: fjzhuozl 時間: 2011-12-20 09:46 標(biāo)題: linux mysql 操作知識 1,查看數(shù)據(jù)庫狀態(tài) 及啟動停止 /etc/init.d/mysqld status /etc/init.d/mysqld start /etc/init.d/mysqld stop
5,root連接數(shù)據(jù)庫有密碼和無密碼: mysql -u root(-uroot) -p mysql
6,增加用戶 test1 密碼 abc,讓它可以在任何主機上登錄,并對所有數(shù)據(jù)庫有查詢,插入,修改,刪除的權(quán)限: 格式: grant select on 數(shù)據(jù)庫.* to 用戶名@登錄主機 identified by "密碼" grant select,insert,update,delete on *.* to test1@"%" Identified by "abc";
7,使用test1賬號從其他主機上登錄命令:
mysql -h 主機名 -u test1 -pabc eg: mysql -h 10.239.48.109 -u test1 -pabc
8,增加一個用戶test2,讓它只可以在localhost上登錄,并可以對數(shù)據(jù)庫mydb進行查詢,插入,修改,刪除的操作, 這樣用戶即使使用知道test2的密碼,他也無法從internet 上直接訪問數(shù)據(jù)庫,只能通過mysql主機上的web頁面來訪問。 grant select,insert,update,delete on mydb.* to test2@localhost identified by "abc"; grant select,insert,update,delete on mydb.* to test2@localhost identified by ""; 設(shè)置無密碼
9,顯示數(shù)據(jù)庫列表: show databases; use mysql 打開庫 show tables;
10,表的操作 describle 表名; 顯示數(shù)據(jù)表的結(jié)構(gòu) create database 庫名; drop database 庫名; create table 表名(字段設(shè)定列表) drop table 表名; delete from 表名;清空表記錄 select * from 表名; 顯示表中的記錄 insert into 表名 values(, ,)
導(dǎo)入數(shù)據(jù): mysqlimport -u root -p123456 < mysql.dbname 將文本數(shù)據(jù)導(dǎo)入數(shù)據(jù)庫: 文本數(shù)據(jù)的字段之間用tab鍵隔開 use test load data local infile "文件名" into table 表名; eg: load data local infile "D:/mysql.txt" into table mytable; 導(dǎo)入.sql 文件命令 use database source d:/mysql.sql;