1、创建数据库
CREATE DATABASE db_name DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;
2、创建用户
CREATE USER 'username'@'host' IDENTIFIED BY 'password';
3、创建用户并赋予权限
grant all privileges on user.* to 'dbname'@'%' identified by 'password'; 这里的‘%’ 指不限制连接来源。
4、查看用户权限等
SELECT DISTINCT CONCAT('User: ''',user,'''@''',host,''';') AS query FROM mysql.user;
或者show grants
5、修改密码
update user set password=password("输入新的密码") where user="root";
或者 update mysql.user set authentication_string=PASSWORD('password') where User='root';
6、刷新权限
flush privileges;