centos7安装mysql8

1.查看是否已经安装了mysql

rpm -qa|grep mysql #无输出说明没有安装

2.下载rpm

2.1 手动下载

打开网址:MySQL Yum存储库
图片
选择linux7,点击下载

2.2 wget下载

wget https://dev.mysql.com/get/mysql80-community-release-el7-10.noarch.rpm

3.安装mysql源

rpm -ivh mysql80-community-release-el7-10.noarch.rpm

4.安装mysql

sudo yum install mysql-community-server

5.启动停止重启mysql

systemctl start mysqld.service
systemctl stop mysqld.service
systemctl restart mysqld.service

设置mysql服务开机自启动

systemctl enable mysqld.service

停止mysql服务开机自启动

systemctl disable mysqld.service

6.mysql配置

6.1 查找初始密码

grep 'temporary password' /var/log/mysqld.log

6.2 登录MySQL

mysql -u root -p'初始密码'

6.3 修改root密码

alter user 'root'@'localhost' identified by 'Su#2023Gjj';

6.4 配置外部访问

use mysql;

update user set host = '%' where user = 'root';

flush privileges;

6.5 大小写问题

vi /etc/my.cnf

lower_case_table_names=1

7.卸载mysql

7.1 yum list命令检查是否安装了Mysql

yum list | grep mysql

7.2 卸载Mysql

yum remove mysql

7.3 删除依赖

查看命令

rpm -qa | grep -i mysql

删除依赖:例

yum remove mysql80-community-release-el7-10.noarch

7.4 删除mysql文件目录

使用 rm -rf 文件或目录 依次删除mysql文件目录,可使用:find / -name mysql 查看相关的文件目录
例:

rm -rf /usr/share/mysql
rm -rf /var/lib/mysql

7.5 更新Yum缓存

yum clean all
posted @ 2023-09-18 22:23  leepandar  阅读(23)  评论(0编辑  收藏  举报