1.Yum安装
###安装前,检测系统是否自带安装mysql
rpm -qa |grep mysql
###如果有安装
rpm -e mysql //普通删除模式
rpm -e --nodeps mysql //强力删除模式
###安装mysql
###去官网下载yum资源包:https://dev.mysql.com/downloads/repo/yum/
wget http://repo.mysql.com/mysql-community-release-el7-5.noarch.rpm
rpm -ivh mysql-community-release-el7-5.noarch.rpm
yum update
yum install mysql-server
###权限设置
chown mysql:mysql -R /var/lib/mysql
###初始化mysql
mysqld --initialize
###启动服务
systemctl start mysqld
###查看版本
[root@centos6 ~]# mysqladmin --version
mysqladmin Ver 8.42 Distrib 5.6.45, for Linux on x86_64
###安装成功后修改root密码
1. mysqladmin -u root password "new_password"
2. mysql> set password for root@localhost = password(‘123’);
3.mysql> use mysql;
mysql> update user set password=password(‘123’) where user=’root’ and host=’localhost’;
mysql> flush privileges;