Centos7通过yum安装Mysql5.7
yum安装mysql
(新版本CentOS自带mariadb而不是mysql,所以要先卸载了,否则会冲突)
查找mariadb
rpm -qa | grep mariadb
卸载mariadb
rpm -e --nodeps mariadb-libs-5.5.52-1.el7.x86_64
安装mysql依赖
yum install vim libaio net-tools
下载mysql源
wget http://repo.mysql.com/yum/mysql-5.7-community/el/7/i386/mysql57-community-release-el7-10.noarch.rpm
安装mysql源
sudo rpm -ivh mysql57-community-release-el7-10.noarch.rpm
开始安装mysql
sudo yum install mysql-server
过程全部输入y
安装完先启动服务systemctl start mysql.service
(停止服务systemctl stop mysql.service)
修改root密码步骤
进入
cd /var/log/
查找初始密码
grep 'temporary password' /var/log/mysqld.log
登陆mysql
mysql -u root -p
修改root密码
update user set authentication_string=password('123abc') where user='root';
因为默认安装的mysql,有空用户名的记录,允许无密码登录,为了安全考虑,需要删除这个功能,可以登录进去mysql,删除掉
mysql>use mysql;
mysql>delete from user where user='';
mysql>flush privileges;