2021-08-25 高版本mysql建立用户

mysql> grant all privileges on . to ‘root’@’%’ identified by ‘Test2021@’ with grant option;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ‘grant all privileges on . to ‘root’@’%’ identified by ‘Test2021@’ wi’ at line 1
mysql>

解决:先创建用户再赋权
create user root@’%’ identified by ‘Test2021@’;
grant all privileges on . to root@’%’ with grant option;

create database DBNAME DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_general_ci; 
create user userName@'%' identified by 'password';
grant all privileges on DBNAME .* to userName@'%' with grant option;

=20210820=============
低版本可以一条语句完成:
GRANT ALL PRIVILEGES ON test_db.* TO ‘test’@’%’ IDENTIFIED BY ‘test&20210920’;

posted @ 2021-08-25 08:55  韧小钊  阅读(45)  评论(0)    收藏  举报