1.上传到服务器中
2. 解压
解压是获取了mysql各个安装包,并不只是直接安装成功了
cd /usr/local/mkdir mysqlcd /datatar -xvf mysql-8.0.28-1.el7.x86_64.rpm-bundle.tar -C /usr/local/mysql查看是否解压成功cd /usr/local/mysql/ll
3.常规操作
#以下三种都是查询是否安装过mysqlrpm -qa | grep mysqlrpm -qa | grep postfixrpm -qa | grep mariadb如果返回有安装,就删掉rpm -e mariadb-libs-5.5.68-1.el7.x86_64rpm -e postfix-2.10.1-9.el7.x86_64rpm -e mariadb-libs-5.5.68-1.el7.x86_64
安装依赖yum install perl -yyum install libaio -yyum install net-tools -y
4.创建mysql用户组和用户,并设置权限
本操作是为安装mysql准备文件夹
groupadd mysqluseradd -r -g mysql mysql创建文件夹(date)、授权mkdir -p /date/mysqlchown mysql:mysql -R /date/mysql
5.安装:
安装顺序(一定不要错)rpm包存放到哪个目录,就去哪个目录下去执行cd /usr/local/mysql/rpm -ivh mysql-community-common-8.0.28-1.el7.x86_64.rpmrpm -ivh mysql-community-libs-8.0.28-1.el7.x86_64.rpm --nodeps --forcerpm -ivh mysql-community-client-8.0.28-1.el7.x86_64.rpm --nodeps --forcerpm -ivh mysql-community-server-8.0.28-1.el7.x86_64.rpm --nodeps --force安装好之后,查看mysql服务的启动状态
6.开启MySQL服务
启动服务systemctl start mysqld查看服务状态systemctl status mysqld# 开机自启systemctl enable mysqld
7.登录
查看默认密码:grep password /var/log/mysqld.log用默认密码登录MySQLmysql -uroot -p输入默认密码登录
8.修改密码为123456
更改复杂的密码,把初始化密码换掉alter user 'root'@'localhost' identified by 'Root123.';重新登陆mysql -uroot -pRoot123.
查看密码规则show variables like 'validate%';更改密码,先修改密码规则set global validate_password.policy=0;set global validate_password.length=1;然后设置新密码ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '123456';#重新登陆mysql -uroot -p123456
9.设置远程连接
9.1MySQL的权限设置、立即生效
use mysql;select user,host from user;update user set host="%" where user="root";select user,host from user;flush privileges;
9.2防火墙状态
systemctl status firewalldsystemctl stop firewalldsystemctl disable firewalld
来源地址:https://blog.csdn.net/weixin_45955039/article/details/130144515