mysql 之后_MYSQL登陆完之后如何操作???(新手求助)
該樓層疑似違規(guī)已被系統(tǒng)折疊?隱藏此樓查看此樓
備份
C:\Documents and Settings\Administrator>mysqldump -uroot -p student>D:\student_b
ack.sql
Enter password: **** C:\Documents and Settings\Administrator> 刪除數(shù)據(jù)庫(kù)
mysql> drop database student;
Query OK, 2 rows affected (0.05 sec) mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| test |
+--------------------+
4 rows in set (0.00 sec) 還原數(shù)據(jù)庫(kù) C:\Documents and Settings\Administrator>mysqldump -uroot -p student>D:\student_b
ack.sql
Enter password: **** C:\Documents and Settings\Administrator>
創(chuàng)建包含多條執(zhí)行語句的觸發(fā)器
先定義一個(gè)新的語句結(jié)束標(biāo)志符號(hào) delimiter $$ (注:紅色部分可為任意符號(hào))
再創(chuàng)建觸發(fā)器
create trigger 觸發(fā)器名 before|after 觸發(fā)事件 on 表名 for each row
begin
要執(zhí)行的語句1;
要執(zhí)行的語句2;
end
$$
最后還原語句結(jié)束標(biāo)志符號(hào)
delimiter ;
建立表的同時(shí)建立索引
create table studentnew2
(
sno char(10),
sbirthday datetime,
sname char(10),
ssex char(10),
sscore numeric(18,0),
classno char(8),
index index_classno (classno)
);
先建立表后在建立索引
mysql> create table studentnew3(
-> sno char(10),
-> sbirthday datetime,
-> sname char(10),
-> ssex char(10),
-> sscore numeric(18,0),
-> classno char(8)
-> );
Query OK, 0 rows affected (0.06 sec) mysql> create index index_classno on studentnew3 (classno);
Query OK, 0 rows affected (0.14 sec)
Records: 0 Duplicates: 0 Warnings: 0
⑴. 在DOS中打開擁有超級(jí)權(quán)限的MySQL的指令
輸入:mysql -h 127.0.0.1 -u root -p
輸入:密碼
⑵. 在DOS中打開普通用戶賬戶的MySQL的指令
輸入:mysql -u賬戶名-p
輸入:密碼
⑶. 創(chuàng)建普通用戶賬戶
第一種:create user '賬戶名'@'localhost' identified by '密碼';
第二種:use mysql;
insert into user(host,user,password,ssl_cipher,x509_issuer,x509_subject)
values('localhost','賬戶名',password('密碼'),'','','');
flush privileges;
第三種:針對(duì)某個(gè)數(shù)據(jù)庫(kù)中某個(gè)數(shù)據(jù)表設(shè)置具有查詢權(quán)限的賬戶
grant select on 某個(gè)數(shù)據(jù)庫(kù).某個(gè)數(shù)據(jù)表 to '賬戶名'@'localhost' identified by '密碼';
⑷. 查詢存在的用戶
select user from mysql.user;
⑸. 查詢當(dāng)前所使用的用戶
select user();
⑹. 查詢用戶的權(quán)限
①. 查詢所有用戶的權(quán)限
select * from mysql.user \G;
②. 查詢某個(gè)用戶的權(quán)限
select grants for '用戶名'@'localhost' \G;
⑺. 修改用戶密碼
①. 通過DOS修改密碼
在還沒登錄進(jìn)MySQL前
輸入:mysqladmin –u 用戶名 –p password "新密碼"
輸入:舊密碼
②. 用set命令修改密碼
修改正在使用的用戶密碼:set password=password("新密碼");
超級(jí)用戶修改普通用戶密碼:set password for '普通用戶名'@ ' localhost'=password("新密碼");
③. 通過跟新系統(tǒng)表修改密碼
use mysql;
update user set password=password("新密碼") where user='用戶名' and host='localhost';
⑻. 刪除普通用戶賬戶
第一種方法:drop user '用戶名'@'localhost';
第二種方法:use mysql;
delete from user where user='用戶名' and host='localhost';
⑼. 權(quán)限管理
①. 對(duì)用戶進(jìn)行授權(quán)
grant 權(quán)力,…,權(quán)力,權(quán)力 on *.* to '用戶名'@'localhost';
(注:紅色部分為權(quán)限內(nèi)容,如: select,create,drop )
②. 收回用戶所擁有權(quán)限
revoke 權(quán)力,…,權(quán)力,權(quán)力 on *.* from '用戶名'@'localhost';
(注:紅色部分為權(quán)限內(nèi)容,如: select,create,drop )
創(chuàng)作挑戰(zhàn)賽新人創(chuàng)作獎(jiǎng)勵(lì)來咯,堅(jiān)持創(chuàng)作打卡瓜分現(xiàn)金大獎(jiǎng)總結(jié)
以上是生活随笔為你收集整理的mysql 之后_MYSQL登陆完之后如何操作???(新手求助)的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Endless OS 5.0 发布:支持
- 下一篇: oracle client 11.2.0