1.檢視已安裝的mysql
rpm -qa|grep mysql

2.移除已安裝的mysql
yum remove mysql*
3.删除mysql中的data目錄
vim /etc/my.cnf
4.删除etc目錄下的my.cnf檔案
rm /etc/my.cnf
5.安裝步驟
6.修改root密碼
SET PASSWORD = PASSWORD('123456');
7.建立使用者
create user 'test'@'localhost' identified by 'pwd123456';
test: 使用者名
pwd123456: 密碼
localhost: 隻有本機可以通路
create user 'test'@'%' identified by 'pwd123456';
%:任何電腦都可以通路
create user 'test'@'192.168.1.1' identified by 'pwd123456';
192.168.1.1:test隻能從這個ip登入'
8.授權
grant all privileges on *.* to 'test'@'%' identified by 'pwd123456' with grant option;
all privileges:表示将所有權限授予給使用者。也可指定具體的權限,如:SELECT、CREATE、DROP等。
on:表示這些權限對哪些資料庫和表生效,格式:資料庫名.表名,這裡寫“*”表示所有資料庫,所有表。如果我要指定将權限應用到test庫的user表中,可以這麼寫:test.user
to:将權限授予哪個使用者。格式:”使用者名”@”登入IP或域名”。%表示沒有限制,在任何主機都可以登入。比如:”yangxin”@”192.168.0.%”,表示yangxin這個使用者隻能在192.168.0IP段登入
identified by:指定使用者的登入密碼
with grant option:表示允許使用者将自己的權限授權給其它使用者
9. 重新整理權限
flush privileges;