linux版MySQL安装(详细教程)

期待您的关注

安装大神带你安装linux版MySQL

目录

linux版MySQL安装(详细教程)

1.linux版MySQL安装

①下载yum Repository

②安装yum Repository

③安装mysql5.7

2.MySQL的设置与配置

1)启动MySQL

①开机自启动

②启动mysql

③查看状态

2)修改密码

①获取临时密码

②登录MySQL

③关闭密码复杂验证

④设置新密码

3)修改权限:方便远程操作

4)卸载yum Repository

3.linux版MySQL的重新安装

1)卸载mysql 删除依赖包

2)清理文件

3)重复上面的1 2步骤


1.linux版MySQL安装

①下载yum Repository

wget -c http://dev.mysql.com/get/mysql57-community-release-el7-10.noarch.rpm

45d06a9bbf364eb1ade9c5fcb0603810.png

②安装yum Repository

yum -y install mysql57-community-release-el7-10.noarch.rpm

dc995ac50d414b53b56e2c9583e53e9c.png


③安装mysql5.7

yum -y --nogpgcheck install mysql-community-server

9217ba362bd448e9b97df5e3bc684797.png

2.MySQL的设置与配置

1)启动MySQL

①开机自启动

systemctl enable mysqld.service

②启动mysql

systemctl start mysqld.service

③查看状态

systemctl status mysqld.service      等到代码前的指示灯变绿色即已经启动

2ae7c40fc47a4788be7b17898bccc55d.png

2)修改密码

①获取临时密码

grep "password" /var/log/mysqld.log

a9eec31ab37143d68b50f4b1008375c7.png

lKvikD4CyP-_

②登录MySQL

8623e682b1b64af98834570a5db1d7ea.png

③关闭密码复杂验证

set global validate_password_policy=0;
set global validate_password_length=1;

ef84cd21c6cf4b35a353673d74e54656.png

④设置新密码

alter user user() identified by "123456";

c7924a3c169941f88f2cefc1f5553cfa.png

3)修改权限:方便远程操作

use mysql;

select host,user,authentication_string from user; --查看权限

GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '123456' WITH GRANT OPTION;  --修改权限

flush privileges;  --刷新权限

select host,user,authentication_string from user; --查看权限

b6a5a6aa19d34eceae10bea8823915f4.png

4)卸载yum Repository

因为安装了yum Repository 以后每次yum操作都会自动更新 所以需要卸载掉

yum -y remove mysql57-community-release-el7-10.noarch

ea0d04f4c05843e688be3691361aafff.png

3.linux版MySQL的重新安装

1)卸载mysql 删除依赖包

rpm -qa |grep -i mysql

yum remove mysql-community mysql-community-server mysql-community-libs mysql-community-common

2)清理文件

find / -name mysql
rm -rf 文件名

3)重复上面的1 2步骤

Logo

旨在为数千万中国开发者提供一个无缝且高效的云端环境,以支持学习、使用和贡献开源项目。

更多推荐