mysql> grant all on *.* to cpp@'10.190.163.107' identified by "cpp";
ERROR 1045 (28000): Access denied for user 'root'@'%' (using password: YES)
这是因为 cdb不能对授权所有 ,去掉了file shutdown权限的 。
所以要查看root用户的权限,按照root用户权限进行授权
这是查看的当前用户
mysql> show grants;
+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Grants for root@% |
+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, RELOAD, PROCESS, REFERENCES, INDEX, ALTER, SHOW DATABASES, SUPER, CREATE TEMPORARY TABLES, LOCK TABLES, EXECUTE, REPLICATION SLAVE, REPLICATION CLIENT, CREATE VIEW, SHOW VIEW, CREATE ROUTINE, ALTER ROUTINE, CREATE USER, EVENT, TRIGGER ON *.* TO 'root'@'%' IDENTIFIED BY PASSWORD '*00D69193DE598A3487D865A90DC3EDF6611D64E6' WITH GRANT OPTION |
+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
若要查看某个用户权限
show Grants for 'user'@'主机';
拷贝root权限后,对cpp用
mysql> GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, RELOAD, PROCESS, REFERENCES, INDEX, ALTER, SHOW DATABASES, SUPER, CREATE TEMPORARY TABLES, LOCK TABLES, EXECUTE, REPLICATION SLAVE, REPLICATION CLIENT, CREATE VIEW, SHOW VIEW, CREATE ROUTINE, ALTER ROUTINE, CREATE USER, EVENT, TRIGGER N'10.190.163.107' IDENTIFIED BY PASSWORD 'cpp' WITH GRANT OPTION ;
ERROR 1372 (HY000): Password hash should be a 41-digit hexadecimal number
mysql> GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, RELOAD, PROCESS, REFERENCES, INDEX, ALTER, SHOW DATABASES, SUPER, CREATE TEMPORARY TABLES, LOCK TABLES, EXECUTE, REPLICATION SLAVE, REPLICATION CLIENT, CREATE VIEW, SHOW VIEW, CREATE ROUTINE, ALTER ROUTINE, CREATE USER, EVENT, TRIGGER ON *.* TO 'cpp'@'10.190.163.107' IDENTIFIED BY PASSWORD 'cpp' WITH GRANT OPTION ;
ERROR 1372 (HY000): Password hash should be a 41-digit hexadecimal number
出现报错信息。
这时需要对密码进行转换后在进行授权。
mysql> select password('cpp');
+-------------------------------------------+
| password('cpp') |
+-------------------------------------------+
| *A5AD891678AA8B21B42877A00F607FEDC44B36A5 |
+-------------------------------------------+
1 row in set (0.01 sec)
mysql> GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, RELOAD, PROCESS, REFERENCES, INDEX, ALTER, SHOW DATABASES, SUPER, CREATE TEMPORARY TABLES, LOCK TABLES, EXECUTE, REPLICATION SLAVE, REPLICATION CLIENT, CREATE VIEW, SHOW VIEW, CREATE ROUTINE, ALTER ROUTINE, CREATE USER, EVENT, TRIGGER ON *.* TO 'cpp'@'10.190.163.107' IDENTIFIED BY PASSWORD '*A5AD891678AA8B21B42877A00F607FEDC44B36A5' WITH GRANT OPTION ;
Query OK, 0 rows affected (0.00 sec)
转载于:https://blog.51cto.com/alwaysyunwei/1262371