两台机器 内网互通
A:192.168.3.39
B:192.168.3.40
以root身份登录
先卸载老版本mysql
已安装centos6.7,选的basic-server模式,默认带了mysql5.1,先卸载掉,再安装
yum list installed|grep mysql
mysql-libs.x86_64
yum remove mysql-libs.x86_64
........
Complete!
yum list installed|grep mysql
无返回,则已卸载成功。
官网下载系统对应的mysql的rpm包
wget https://repo.mysql.com//mysql57-community-release-el6-9.noarch.rpm
安装rpm包
rpm -Uvh mysql57-community-release-el6-9.noarch.rpm
warning: mysql57-community-release-el6-9.noarch.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
Preparing... ########################################### [100%]
1:mysql57-community-relea########################################### [100%]
选择安装版本
When using the MySQL Yum repository, the latest GA release of MySQL is selected for installation by default.
会默认最新的正式版本(GA)
yum repolist all | grep mysql
mysql-connectors-community MySQL Connectors Community enabled: 30
mysql-connectors-community-source MySQL Connectors Community - So disabled
mysql-tools-community MySQL Tools Community enabled: 42
mysql-tools-community-source MySQL Tools Community - Source disabled
mysql-tools-preview MySQL Tools Preview disabled
mysql-tools-preview-source MySQL Tools Preview - Source disabled
mysql55-community MySQL 5.5 Community Server disabled
mysql55-community-source MySQL 5.5 Community Server - So disabled
mysql56-community MySQL 5.6 Community Server disabled
mysql56-community-source MySQL 5.6 Community Server - So disabled
mysql57-community MySQL 5.7 Community Server enabled: 164
mysql57-community-source MySQL 5.7 Community Server - So disabled
mysql80-community MySQL 8.0 Community Server disabled
mysql80-community-source MySQL 8.0 Community Server - So disabled
可以看到默认选的5.7版本
如果要选择其他版本,可以编辑/etc/yum.repos.d/mysql-community.repo 文件,修改对应版本的enabled=1
确认要安装的版本
yum repolist enabled | grep mysql
mysql-connectors-community MySQL Connectors Community 30
mysql-tools-community MySQL Tools Community 42
mysql57-community MySQL 5.7 Community Server 164
开始安装
yum install mysql-community-server
.......
Complete!
安装完成。
启动mysql服务
service mysqld start
Initializing MySQL database: [ OK ]
Installing validate password plugin: [ OK ]
Starting mysqld: [ OK ]
查看mysql状态
service mysqld status
mysqld (pid 37204) is running...
mysql5.7默认新建了一个临时密码,存在mysqld.log文件,查看临时密码
grep 'temporary password' /var/log/mysqld.log
2017-01-13T16:36:26.580447Z 1 [Note] A temporary password is generated for root@localhost: **5n-(#ex5xqyV**
更改root密码
mysql -uroot -p
Enter password:
使用临时密码 5n-(#ex5xqyV 登录后,修改root密码
ALTER USER 'root'@'localhost' IDENTIFIED BY 'MyNewPass4!';
新密码太简单的话,会报ERROR 1819 (HY000): Your password does not satisfy the current policy requirements
因为增加了密码强度验证插件validate_password,相关参数设置的较为严格