Yum安装MySQL
环境准备
关闭防火墙
1
| systemctl stop firewalld && systemctl disable firewalld
|
1
| setenforce 0 && sed -i 's/SELINUX=.*/SELINUX=disabled/g' /etc/selinux/config
|
安装常用软件
1
| yum install -y wget net-tools bash-completion
|
更新软件
使用yum源安装
下载mysql安装源
1
| https://dev.mysql.com/downloads/repo/yum/
|
根据系统版本点击Download
点击下载rpm包 或者右键复制链接
1
| wget https://dev.mysql.com/get/mysql80-community-release-el7-10.noarch.rpm
|
1
| rpm -ivh mysql80-community-release-el7-10.noarch.rpm
|
配置安装源
1 2
| cd /etc/yum.repos.d/ vim mysql-community.repo
|
根据需求版本号配置
我这里直接装8.0 所以不需要修改
安装mysql
1
| yum -y install mysql-community-server
|
启动MySQL并设置开机自启
1
| systemctl start mysqld && systemctl enable mysqld
|
修改mysql初始化密码及权限
1
| grep password /var/log/mysqld.log
|
登录数据库
1
| mysql -p'密码' ##注意带特殊字符的必须要加单引号
|
配置密码及权限
1 2 3 4
| alter user 'root'@'localhost' identified by 'Jianren@123'; grant all privileges on *.* to 'root'@'localhost' ; flush privileges; exit ;
|
使用rpm包安装
下载mysql rpm 安装包 。选择对应的操作系统版本官网地址 下载对应的rpm包
上传并解压
1
| tar xf mysql-8.0.20-1.el7.x86_64.rpm-bundle.tar
|
安装
启动MySQL并设置开机自启
1
| systemctl start mysqld && systemctl enable mysqld
|
修改mysql初始化密码及权限
1
| grep password /var/log/mysqld.log
|
登录数据库
1
| mysql -p'密码' ##注意带特殊字符的必须要加单引号
|
1 2 3 4
| alter user 'root'@'localhost' identified by 'Jianren@123'; grant all privileges on *.* to 'root'@'localhost' ; flush privileges; exit ;
|