查看镜像是否挂载
df -h
#本地镜像挂载
mount /dev/sr0 /mnt
#配置本地镜像源
cd /etc/yum.repos.d/
#创建备份文件夹,将默认的镜像文件备份至该文件夹
mkdir bak
mv *.repo bak/
#创建并编辑本地镜像配置文件
vi base.repo
[local]
name=local
baseurl=file:///mnt
gpgcheck=0
enabled=1
安装wget
yum -y install wget
设置远程华为镜像
wget -o CentOS-Base.repo https://repo.huaweicloud.com/repository/conf/CentOS-7-reg.repo
将本地镜像中的CentOS-Base.repo移入CentOS-Base.repo.bak中,防止华为云将本地的CentOS-Base.repo拖出
mv CentOS-Base.repo CentOS-Base.repo.bak
安装本地文件传输插件
yum -y install lrzsz
############################ mysql 5.7安装 ############################
在CentOS中安装mysql
wget https://dev.mysql.com/get/mysql57-community-release-el7-9.noarch.rpm
rpm -ivh mysql57-community-release-el7-9.noarch.rpm
安装mysql服务
yum -y install mysql-server
#尝试开启mysql服务
systemctl start mysqld
#查看服务状态
systemctl status mysqld
#关闭服务进行字符集配置
systemctl stop mysqld
#安装vim编辑器(可显示颜色)
yum -y install vim
vim /etc/my.cnf
[client]
default-character-set = utf8mb4
[mysql]
default-character-set = utf8mb4
[mysqld]
character-set-client-handshake = FALSE
character-set-server = utf8mb4
collation-server = utf8mb4_unicode_ci
systemctl start mysqld
命令行生成并获取临时密码
grep ‘temporary password’ /var/log/mysqld.log
临时密码
2021-05-25T04:19:02.168221Z 1 [Note] A temporary password is generated for root@localhost: p8o.Wyhwo-vd
利用临时密码登录,并修改密码
mysql -u root -p[p8o.Wyhwo-vd]
退出mysql
exit
如果 /var/log/mysqld.log 中不存在初始化临时密码
通过一下途径设置免密登录
#1、关闭mysql服务
systemctl stop mysqld
#2、修改匹配文件启动免密登录
vim /etc/my.cnf
[mysqld]
skip-grant-tables
#3、启动mysql服务
systemctl start mysqld
#4、免密登录
mysql #回车
#5、立即修改本地访问root账号密码后退出mysql
use mysql;
#update user set password/authentication_string=password('1234') where user='root';
update user set authentication_string=password('123456') where user='root';
exit;
#6、关闭mysql服务,
systemctl stop mysqld
#删除配置信息skip-grant-tables
vim /etc/my.cnf
#再次启动mysql服务后可以使用之前修改的密码正常登录
systemctl start mysqld
mysql -u root -p
password:123456
#7、必须在进行其他操作前修改符合密码策略要求的密码
alter user 'root'@'localhost' identified by '@12A3a4pola';
#7.1、如果需要修改密码难度等级
set global validate_password_policy=0;
flush privileges;
#7.2、再次重置密码:最小长度8(singlekb password:12345678)
alter user 'root'@'localhost' identified by '12345678';
#启动远程访问(数据库用户名:root,密码:RENZHIJIE@1997913)
grant all on . to root@’%’ identified by ‘RENZHIJIE@1997913’;
连接本地数据库
mysql -uroot -p -h192.168.1.139
password:1997913