1. 下载mysql的yum源
# cd /usr/local/ # wget http://dev.mysql.com/get/mysql57-community-release-el7-11.noarch.rpm |
2. 安装mysql的yum源
# rpm -ivh mysql57-community-release-el7-11.noarch.rpm |
3. 查看当前启用的mysql版本
# yum repolist enabled | grep mysql |
4. 安装mysql
# yum install mysql-community-server 碰到选择,使用y即可 |
5. 修改默认字符集
# vi /etc/my.cnf 在[mysqld]新增 character_set_server = utf8 |
6. 启动mysql
# systemctl start mysqld |
7. 修改root密码
# 查看默认的密码 grep 'temporary password' /var/log/mysqld.log mysql –uroot –p 上面的密码 进入后, 修改密码 mysql> set password for 'root'@'localhost'=password('新密码'); |
8. 创建用户及授权
创建普通用户 mysql> create user '普通用户'@'%' IDENTIFIED BY '密码'; 授权 mysql> GRANT SELECT,INSERT,UPDATE,DELETE ON *.* TO 普通用户@"%";
创建管理员用户 mysql> CREATE USER 'admin'@'%' IDENTIFIED BY '密码'; 授权 mysql> GRANT ALL PRIVILEGES ON *.* TO 'admin'@'%';
使权限生效 mysql> flush privileges; |
更多内容,参见: https://yq.aliyun.com/articles/654980