本篇笔记记录了在CentOS 6.9中使用yum安装MySQL 5.7的过程
官网下载yum资源库rpm
wget -c https://dev.mysql.com/get/mysql80-community-release-el6-2.noarch.rpm
安装yum资源库
rpm -Uvh mysql80-community-release-el6-2.noarch.rpm
修改库配置
vim /etc/yum.repos.d/mysql-community.repo
启用MySQL 5.7 Community Server,禁用MySQL 8.0 Community Server
[mysql57-community]
name=MySQL 5.7 Community Server
baseurl=http://repo.mysql.com/yum/mysql-5.7-community/el/6/$basearch/
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql
[mysql80-community]
name=MySQL 8.0 Community Server
baseurl=http://repo.mysql.com/yum/mysql-8.0-community/el/6/$basearch/
enabled=0
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql
安装mysql
yum install mysql-community-server
启动并初始化mysql
service mysqld start
初始化 MySQL 数据库: [确定]
正在启动 mysqld: [确定]
查看root默认密码
grep 'temporary password' /var/log/mysqld.log
2019-03-03T17:22:33.353738Z 1 [Note] A temporary password is generated for root@localhost: 1QPe_VwJNj6z
1QPe_VwJNj6z
便是要找的密码
登录mysql
mysql -uroot -p
......
mysql> show databases;
ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.
报错:ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.
提示要先修改默认密码
#测试环境的话密码不需要那么复杂,可以降低级别
set global validate_password_policy=0;
set global validate_password_length=1;
#修改密码
alter user 'root'@'localhost' identified by 'vagrant'
ok,安装完毕!
提示:
如果在执行service mysqld restart
或service mysqld stop
时无响应,请查看logtail -f /var/log/mysqld.log
如果一直提示如下信息
InnoDB: Waiting for page_cleaner to finish flushing of buffer pool
说明服务器时区有问题,可以修改时区或ps aux | grep mysqld
查看进程ID,然后kill -9 进程ID
将其杀掉就ok了