mysql创建账号

Posted kisf

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了mysql创建账号相关的知识,希望对你有一定的参考价值。

1、创建账号
1)只读账号
GRANT USAGE ON *.* TO ‘testgao_r‘@‘192.168.1.1‘ IDENTIFIED BY ‘password‘ WITH MAX_QUERIES_PER_HOUR 14400000 MAX_UPDATES_PER_HOUR 7200000 MAX_CONNECTIONS_PER_HOUR 14400000 MAX_USER_CONNECTIONS 2000;
GRANT SELECT, EXECUTE, SHOW VIEW ON `testdb`.* TO ‘testgao_rw‘@‘192.168.1.1‘;
2)读写账号
GRANT USAGE ON *.* TO ‘testgao_rw‘@‘192.168.1.1‘ IDENTIFIED BY ‘password‘ WITH MAX_QUERIES_PER_HOUR 14400000 MAX_UPDATES_PER_HOUR 7200000 MAX_CONNECTIONS_PER_HOUR 14400000 MAX_USER_CONNECTIONS 2000;
GRANT SELECT, INSERT, UPDATE, DELETE, INDEX, CREATE TEMPORARY TABLES, EXECUTE, SHOW VIEW ON `testdb`.* TO ‘testgao_rw‘@‘192.168.1.1‘;
3)管理账号
GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, RELOAD, PROCESS, REFERENCES, INDEX, ALTER, SHOW DATABASES, CREATE TEMPORARY TABLES, LOCK TABLES, EXECUTE, REPLICATION SLAVE, REPLICATION CLIENT, CREATE VIEW, SHOW VIEW, CREATE ROUTINE, ALTER ROUTINE, CREATE USER, EVENT, TRIGGER ON *.* TO ‘admin‘@‘10.%.%.%‘ IDENTIFIED BY ‘pass123‘ WITH GRANT OPTION;
2、删除账号
DROP USER [email protected]‘192.168.1.1‘;
3、查询账号权限
select * from mysql.user where user=‘letv_ugc_r‘ and host=‘10.127.92.157‘;
4、移除权限
REVOKE DELETE ON testdb FROM ‘testgao_rw‘@‘192.168.1.1‘;
5、修改密码
SET PASSWORD FOR ‘testgao‘@‘192.168.1.1‘ = PASSWORD(‘newpassword‘);

















以上是关于mysql创建账号的主要内容,如果未能解决你的问题,请参考以下文章

mysql从库设置全局只读,并创建普通账号

mysql创建用户账号出错

MYSQL账号创建,授权,删除

三个步骤为Mysql添加只读账号

三个步骤为Mysql添加只读账号

MySQL 数据库--权限管理