1. 账号操作

注意不要忽略 ;

1.1. 登录

mysql -u root -p

1.2. 选择db

use mysql;

1.3. 查看所有用户

SELECT User, Host, Password FROM mysql.user;
#或
SELECT DISTINCT User FROM mysql.user;

1.4. 新增账号

#localhost(本地)  && % (所有ip)
insert into mysql.user(Host,User,Password) values("%","alonexy",password("123456"));
#严格模式
GRANT USAGE ON *.* TO 'alonexy'@'%' IDENTIFIED BY '123456' WITH GRANT OPTION;

1.5. 刷新权限

flush privileges;

1.6. 分配权限

grant select,update (all 全部) on 数据库名称.表名称 to用户名@用户地址 identified by ‘连接口令’;
grant all on dbname.* to alonexy@"%" identified by "123321aa";

1.7. 刷新权限

flush privileges;

1.8. 修改用户密码

update mysql.user set password=password('123456') where User="alonexy" and Host="%";

results matching ""

    No results matching ""