alter user 'maxzhao'@'localhost' identified by "maxzhao"; alter user 'maxzhao'@'localhost' identified with mysql_native_password by "maxzhao"; alter user 'maxzhao'@'localhost' identified with caching_sha2_password by "maxzhao";
CREATE USER 'maxzhao'@'localhost' IDENTIFIED BY 'maxzhao'; grant all privileges on *.* TO 'maxzhao'@'localhost' WITH GRANT OPTION;
CREATE USER 'maxzhao'@'%' IDENTIFIED BY 'maxzhao'; GRANT ALL PRIVILEGES ON *.* TO 'maxzhao'@'%' WITH GRANT OPTION;
CREATE USER 'maxzhao'@'localhost' IDENTIFIED BY 'maxzhao'; GRANT RELOAD,PROCESS ON *.* TO 'maxzhao'@'%'; Flush privileges; -- #显示账号及权限相关信息 SHOW GRANTS FOR 'maxzhao'@'localhost';
alter user 'maxzhao'@'localhost' password history 5; -- 查看表结构 desc mysql.user; -- 查看当前用户策略 select user,host,Password_reuse_history from mysql.user; -- 查看mysql密码历史记录 desc mysql.password_history;
二进制日志
1 2 3
-- log_bin -- 查看变量 show variables like '%log_bin%';
-- 创建角色 create role 'role_w'; select host,user,authentication_string from mysql.user ; -- 给角色授权 grant insert,update,delete,select on *.* to 'role_w'; -- 创建用户 create user 'maxzhao_1' identified by 'maxzhao'; -- 授角色权限 grant 'role_w' to 'maxzhao_1'; -- 查看用户权限 show grants from 'maxzhao_1'; show grants from 'maxzhao_1' using 'role_w'; -- 用户:查询用户的当前角色,会发现当前尾NONE select currnt_role(); -- 用户:我们需要设置当前角色 set role 'role_w'; -- 为用户设置默认角色 set default role 'role_w' to 'maxzhao_1'; set default tole all to 'maxzhao_1'; -- 查看用户角色关联信息 select * from mysql.default_role; -- 用户所授予的角色信息 select * from mysql.role_edges;
撤销权限命令:
1
revoke insert,update on *.* from ‘role_w';
基本操作语句
1 2 3 4
-- 添加字段 alter table app_user add app_role_ids varchar(2000); -- 修改字段 alter table app_user modify app_role_ids varchar(2000) null comment '用户角色表';
这里在 arch linux 下有可能会出现 mysqld: error while loading shared libraries: libicuuc.so.63: cannot open shared object file: No such file or directory ,需要下载 icu63,用软件管理器下载很方便,或者添加 yaourt下载也很方便。
wget http://download.icu-project.org/files/icu4c/63.1/icu4c-63_1-src.tgz tar -zxvf icu4c-63_1-src.tgz cd icu/source ./configure --prefix=/usr make # make 需要 sudo pacman -S make cd lib cp libicuuc.so.63* /usr/lib cp libicui18n.so.63* /usr/lib cp libicudata.so.63* /usr/lib
文件报错问题
1 2 3
cd /var/lib/mysql/ rm * mysqld --initialize-insecure
启动报错
1 2 3
# [InnoDB] The innodb_system data file 'ibdata1' must be writable