1. 查看是否已安装了mysql
yum list installed | grep mysql
yum -y remove 名称
2. 添加源
5.6版本
wget http://repo.mysql.com/mysql-community-release-el7-5.noarch.rpm
sudo rpm -ivh mysql-community-release-el7-5.noarch.rpm5.7版本
wget http://dev.mysql.com/get/mysql57-community-release-el7-7.noarch.rpm
sudo rpm -ivh mysql57-community-release-el7-7.noarch.rpm
3. 安装mysql
sudo yum -y install mysql-server
4. 修改mysql的密码
mysql 5.6
# 重启服务
service mysqld restart# 进入mysql
mysql -u root
# 切换库
use mysql;
# 修改root用户的密码
update user set password=password('1234') where user='root';
# 重启mysql
service mysqld restart
mysql 5.7
设置忽略密码
vim /etc/my.cnf
在[mysqld]中添加 skip-grant-tables# 重启服务
/bin/systemctl restart mysqld.service修改密码
update mysql.user set authentication_string=password('the$1234') where user='root';刷新
flush privileges;删除忽略密码
vim /etc/my.cnf
在[mysqld]中添加 skip-grant-tables# 重启服务
/bin/systemctl restart mysqld.service