1. 下载指定版本mysql
1.1 下载地址
宿主计算机安装的是mysql community server 5.5.27版本,下载地址:https://downloads.mysql.com/archives/community/
- 下载tar文件
- 下载rpm文件
1.2 通过ftp上传到centos7中或者使用wget命令下载mysql文件
- 使用filezilla上传
详见 https://blog.csdn.net/CGS_______/article/details/95586330 - 使用wget下载
wget https://downloads.mysql.com/archives/get/file/mysql-5.5.27.tar.gz
wget https://downloads.mysql.com/archives/get/file/MySQL-server-5.5.27-1.el6.x86_64.rpm
wget https://downloads.mysql.com/archives/get/file/MySQL-client-5.5.27-1.el6.x86_64.rpm
2. 安装配置msyql
2.1 安装mysql
使用rpm命令与管道查询mysql
rpm -aq | grep -i mysql
卸载mysql
rpm -e --nodeps [rpm查询出来的包名]
安装mysql(我将rpm文件放到了/usr/local/src/mysql目录下)
cd /usr/local/src/mysql
rpm -ivh MySQL-server-5.5.27-1.el6.x86_64.rpm
rpm -ivh MySQL-client-5.5.27-1.el6.x86_64.rpm
2.2 启动mysql
查看myslq运行状态
service mysql status
启动mysql服务
service mysql start
2.3 修改mysql密码
在安装MySQL-server-5.5.27-1.el6.x86_64.rpm完成后会有提示如何修改密码
--第一次登录时需要给root用户设置密码
/usr/bin/mysqladmin -u root password 'new-password'
--登入mysql后可以更改密码
set password=password('password');
2.4 开放3306端口
开放3306端口并重新加载防火墙设置
firewall-cmd --zone=public --add-port=3306/tcp --permanent
firewall-cmd --reload
firewall-cmd --list-ports
2.5 给root分配全部权限
一般不应该给root分配所有权限
grant all privileges on *.* to 'root' @'%' identified by 'new-password'
2.6 宿主计算机测试连接
2.7 设置开启自动启动
chkconfig --add mysql
chkconfig mysql on
chkconfig | grep mysql