首页 > 代码库 > mysql root 维护

mysql root 维护


修改root密码:

mysql -uroot -paaa
mysql> use mysql;
mysql> UPDATE user SET password=password("aaa") WHERE user=‘root‘;  
mysql> flush privileges;
mysql> exit;

# 重启服务
service mysqld restart


增加用户:

insert into user(Host,User,Password) values("localhost","root",password("113355"));
insert into user(Host,User,Password) values("%","root",password("113355"));
insert into user(Host,User,Password) values("iz11jtfubrxz","root",password("113355"));

更新用户信息使得用户可以查看mysql库:

update user set Select_priv =‘Y‘ where user = ‘root‘;
update user set Insert_priv =‘Y‘ where user = ‘root‘;
update user set Update_priv =‘Y‘ where user = ‘root‘;
update user set Delete_priv =‘Y‘ where user = ‘root‘;
update user set Create_priv =‘Y‘ where user = ‘root‘;
update user set Drop_priv =‘Y‘ where user = ‘root‘;
update user set Reload_priv =‘Y‘ where user = ‘root‘;
update user set Shutdown_priv =‘Y‘ where user = ‘root‘;
update user set Process_priv =‘Y‘ where user = ‘root‘;
update user set File_priv =‘Y‘ where user = ‘root‘;
update user set Grant_priv =‘Y‘ where user = ‘root‘;
update user set References_priv =‘Y‘ where user = ‘root‘;
update user set Index_priv =‘Y‘ where user = ‘root‘;
update user set Alter_priv =‘Y‘ where user = ‘root‘;
update user set Show_db_priv =‘Y‘ where user = ‘root‘;
update user set Super_priv =‘Y‘ where user = ‘root‘;
update user set Create_tmp_table_priv =‘Y‘ where user = ‘root‘;
update user set Lock_tables_priv =‘Y‘ where user = ‘root‘;
update user set Execute_priv =‘Y‘ where user = ‘root‘;
update user set Repl_slave_priv =‘Y‘ where user = ‘root‘;
update user set Repl_client_priv =‘Y‘ where user = ‘root‘;
update user set Create_view_priv =‘Y‘ where user = ‘root‘;
update user set Show_view_priv =‘Y‘ where user = ‘root‘;
update user set Create_routine_priv =‘Y‘ where user = ‘root‘;
update user set Alter_routine_priv =‘Y‘ where user = ‘root‘;
update user set Create_user_priv =‘Y‘ where user = ‘root‘;
update user set Event_priv =‘Y‘ where user = ‘root‘;
update user set Trigger_priv =‘Y‘ where user = ‘root‘;


 

my.cnf配置

[mysqld]
#datadir=/var/lib/mysql
datadir=/xxx/mydqldate/
#socket=/var/lib/mysql/mysql.sock
socket=/data/mydqldate/mysql.sock
user=mysql
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0
default-character-set=utf8
lower_case_table_names=1
#skip-grant-tables

[client]
default-character-set=utf8
[mysql]
default-character-set=utf8

[mysqld_safe]
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid

mysql root 维护