用户管理
create ‘user‘@‘host‘ indentified by ‘PASSWORD‘;
grant all privileges on DB_NAME.TABLE_NAME to ‘user‘@‘host‘ identified by ‘PASSWORD‘;
use mysq; flush privileges; select user, host, password from user;
show grants for ‘user‘@‘host‘;
revoke select on test.test1 from ‘USER‘@‘localhost‘;
select * from user where user=‘root‘ \G;
select * from db \G;
忘记密码:
--skip-grant-tables # 跳过用户设置的权限表, 可以无密码登陆 --skip-network # 禁止掉网络, 防止被入侵
killall mysqld mysqld_safe --skip-network --skip-grant-tables & # 以一个 daemon 的方式重新运行 mysqld update user set password=password(‘PASSWORD‘) where user=‘root‘; service restart mariadb
用户密码修改:
? mysqladmin -u USERNAME -h HOSTNAME password ‘NEW_PASS‘ -p mysql> SET PASSWORD FOR ‘USERNAME‘@‘HOST‘=PASSWORD(‘new_pass‘); mysql> UPDATE mysql.user SET PASSWORD=PASSWORD(‘new_pass‘) WHERE CONDITION;