在进入mysql之后,输入相应的语句:
GRANT ALL PRIVILEGES ON *.* TO ‘myuser‘@‘%‘ IDENTIFIED BY ‘mypassword‘ WITH GRANT OPTION; 其中‘myuser‘、‘mypassword‘ 需要替换成实际的用户名和密码。 例如GRANT ALL PRIVILEGES ON *.* TO ‘root‘@‘%‘ IDENTIFIED BY ‘admin‘ WITH GRANT OPTION;
可能会报错,如下:
ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.
改正:
mysql> set password=password(‘admin‘); Query OK, 0 rows affected, 1 warning (0.01 sec) mysql> GRANT ALL PRIVILEGES ON *.* TO ‘root‘@‘%‘ IDENTIFIED BY ‘admin‘ WITH GRANT OPTION; FLUSH PRIVILEGES; Query OK, 0 rows affected, 1 warning (0.00 sec) Query OK, 0 rows affected (0.00 sec) mysql> FLUSH PRIVILEGES; Query OK, 0 rows affected (0.00 sec) mysql> quit; Bye
成功修改
时间: 2024-11-06 07:17:24