修改root密碼
1.以root身份在終端登陸(必須)
2.輸入 mysqladmin -u root -p password ex
后面的 ex 是要設(shè)置的密碼
3.回車(chē)后出現(xiàn) Enter password
輸入就密碼,如果沒(méi)有,直接回車(chē)
打開(kāi)遠(yuǎn)程訪問(wèn)權(quán)限
MariaDB [(none)]> grant all privileges on . to 'root'@'%' identified by 'root4xml004a' with grant option;
Query OK, 0 rows affected (0.00 sec)
MariaDB [(none)]> flush privileges;
Query OK, 0 rows affected (0.00 sec)
如果遠(yuǎn)程還是沒(méi)有辦法訪問(wèn),那就開(kāi)啟3306端口就行:
[root@marslv yum.repos.d]# iptables -A INPUT -p tcp --dport 3306 -j ACCEPT
[root@marslv yum.repos.d]# service iptables save
[root@marslv yum.repos.d]# service iptables restart
創(chuàng)建用戶(hù)
//創(chuàng)建用戶(hù)
mysql> insert into mysql.user(Host,User,Password) values("localhost","admin",password("admin"));
//刷新系統(tǒng)權(quán)限表
mysql>flush privileges;
這樣就創(chuàng)建了一個(gè)名為:admin 密碼為:admin 的用戶(hù)。
創(chuàng)建數(shù)據(jù)庫(kù)(在root權(quán)限下)
create database mydb;
//授權(quán)admin用戶(hù)擁有mydb數(shù)據(jù)庫(kù)的所有權(quán)限。
grant all privileges on mydb.* to admin@localhost identified by 'admin';
//刷新系統(tǒng)權(quán)限表
mysql>flush privileges;
刪除用戶(hù)。
@>mysql -u root -p
@>密碼
mysql>DELETE FROM user WHERE User="admin" and Host="localhost";
mysql>flush privileges;
//刪除用戶(hù)的數(shù)據(jù)庫(kù)
mysql>drop database mydb;
修改指定用戶(hù)密碼。
@>mysql -u root -p
@>密碼
mysql>update mysql.user set password=password('新密碼') where User="admin" and Host="localhost";
mysql>flush privileges;