一.mysql安装
mysql下载地址:MySQL下载
系统环境:CentOS Linux release 8.2.2004 (Core)
mysql版本:Ver 8.0.23 for Linux on x86_64 (MySQL Community Server - GPL)
1.下载mysql并上传到centos服务器
2.解压mysql
tar xvf mysql-8.0.23-1.el8.x86_64.rpm-bundle.tar
3.通过RPM命令安装client common libs server
rpm -ivh mysql-community-client-8.0.23-1.el8.x86_64.rpm --nodeps --force
rpm -ivh mysql-community-common-8.0.23-1.el8.x86_64.rpm --nodeps --force
rpm -ivh mysql-community-libs-8.0.23-1.el8.x86_64.rpm --nodeps --force
rpm -ivh mysql-community-server-8.0.23-1.el8.x86_64.rpm --nodeps --force
4.查看mysql的安装包
rpm -qa |grep mysql
5.通过以下命令,完成对mysql数据库的初始化和相关配置
mysqld --initialize; #在/varlog/mysqld.log生成随机密码
chown mysql:mysql /var/lib/mysql -R #更改mysql数据库目录所属用户鸡所属组
systemctl start mysqld.service #启动mysql数据库服务
systemctl enable mysqld #为mysql设置开机自启
systemctl status mysqld.service #查看mysql服务状态
6.查看mysql数据库的密码
cat /var/log/mysqld.log |grep password
7.进入mysql数据库登录界面
mysql -u root -p
8.修改mysql数据库密码
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '123456';
9.退出mysql验证新密码