mysql5.7安装
- 安装新版mysql前,需将系统自带的mariadb-lib卸载
rpm -qa|grep mariadb
根据具体内容卸载
rpm -e --nodeps mariadb-libs-5.5.56-2.el7.x86_64
rpm -e --nodeps mariadb-server-5.5.56-2.el7.x86_64
rpm -e --nodeps mariadb-5.5.56-2.el7.x86_64
到官网下载安装包
https://dev.mysql.com/downloads/mysql/
选择对应的版本下载(记录的时候官网已经没有5.7.28的版本了)
- 解压压缩包
tar -xvf mysql-5.7.28-1.el7.x86_64.rpm-bundle.tar
- 安装mysql-community-common-5.7.28-1.el7.x86_64.rpm
rpm -ivh mysql-community-common-5.7.28-1.el7.x86_64.rpm
- 安装mysql-community-libs-5.7.28-1.el7.x86_64.rpm
rpm -ivh mysql-community-libs-5.7.28-1.el7.x86_64.rpm
- 安装mysql-community-client-5.7.28-1.el7.x86_64.rpm
rpm -ivh mysql-community-client-5.7.28-1.el7.x86_64.rpm
- 安装mysql-community-server-5.7.28-1.el7.x86_64.rpm
rpm -ivh mysql-community-server-5.7.28-1.el7.x86_64.rpm
- 初始化
mysqld --defaults-file=/etc/my.cnf --initialize --user=mysql
- 开启服务
service mysqld start
- 获取初始化密码
cat /var/log/mysqld.log
这一窜乱码一样的东西
- 登录mysql
mysql -uroot -peHNdO+EI,2vn
这时无论输入什么命令都提示
You must reset your password using ALTER USER statement before executing this statement.
修改密码就好
SET PASSWORD = PASSWORD('root');
- 最后修改下root密码
update mysql.user set authentication_string='root' where user='root';
就可以重新用新密码登录了