- 下载mysql源安装包
wget http://dev.mysql.com/get/mysql57-community-release-el7-8.noarch.rpm
- 安装mysql源
yum localinstall mysql57-community-release-el7-8.noarch.rpm
- 检查mysql源是否安装成功
yum repolist enabled | grep "mysql.*-community.*"
- 安装MySQL
yum install mysql-community-server
- 启动MySQL服务
systemctl start mysqld
- 查看MySQL的启动状态
systemctl status mysqld
- 开机启动
systemctl enable mysqld
systemctl daemon-reload
- 修改密码策略和默认编码
//打开配置文件
vi /etc/my.cnf
//去掉密码策略验证
validate_password = off
//修改默认编码,在[mysqld]下增加
character_set_server=utf8
init_connect='SET NAMES utf8'
//重启服务
systemctl restart mysqld
- 修改root本地登录密码
//获取自动生成的密码,如果没有,则可以直接登录
grep 'temporary password' /var/log/mysqld.log
//登录
mysql -uroot -p
//修改密码
set password for 'root'@'localhost'=password('MyNewPass4!');
- 远程登录
//使用mysql数据库
use mysql;
//更新用户表
update user set host = '%' where user='root' and host='localhost';
//重启服务
systemctl restart mysqld
相关参数及配置文件路径:
默认配置文件路径:
配置文件:/etc/my.cnf
日志文件:/var/log//var/log/mysqld.log
服务启动脚本:/usr/lib/systemd/system/mysqld.service
socket文件:/var/run/mysqld/mysqld.pid
基本照抄底下的参考文章,只是添加了一点信息好整理成自己方便使用的模式。
参考:
http://blog.csdn.net/xyang81/article/details/51759200