70°

yum安装mysql5.7 及账户管理

安装及账户相关配置,安装时需要gcc等提前进行安装 

//下载
wget -i -c http://dev.mysql.com/get/mysql57-community-release-el7-10.noarch.rpm
//安装源
yum -y install mysql57-community-release-el7-10.noarch.rpm
//安装服务
yum -y install mysql-community-server
//启动服务
systemctl start  mysqld.service
//查看日志内密码
grep "password" /var/log/mysqld.log
//首次进入mysql后需重置密码 这里密码需要一定的复杂度不然会报错
ALTER USER 'root'@'localhost' IDENTIFIED BY 'new password';
//删除掉yum里myql  不删除可能会自动更新
yum -y remove mysql57-community-release-el7-10.noarch
//创建账户 host可以使用ip或通配符%
CREATE USER 'username'@'host' IDENTIFIED BY 'password';
//配置权限 privileges 部分可设置select,deleted等权限  表库名等选项
GRANT privileges ON databasename.tablename TO 'username'@'host' // WITH GRANT OPTION;  加这部分可赋予授权权限
//更新权限 不更新需重启才能生效
flush privileges;
//重置密码
SET PASSWORD FOR 'username'@'host' = PASSWORD('newpassword');
//删除权限
REVOKE privilege ON databasename.tablename FROM 'username'@'host';
//删除用户
DROP USER 'username'@'host';

 

 

本文由【曲文】发布于开源中国,原文链接:https://my.oschina.net/u/3538113/blog/3072060

全部评论: 0

    我有话说: