mysq5.7 yum方式安装

环境  centos7.6

当工作需要部署mysql时,通过手动上传安装包以及依赖包的方式安装mysql会比较麻烦,可以添加官方yum源,来实现自动安装依赖,方便快捷,这里已mysql5.7为例,其他版本差不多。

查看当前yum仓库是否包含mysql-server相关包,

[root@k8smaster ~]# yum whatprovides mysql-server

下载 mysql的yum仓库文件包

wget http://repo.mysql.com/yum/mysql-5.7-community/el/7/x86_64/mysql57-community-release-el7-10.noarch.rpm
rpm -ivh mysql57-community-release-el7-10.noarch.rpm

再次查看仓库是否有mysql相关安装包,已存在

[root@jenkins ~]# yum whatprovides mysql-server

开始使用yum安装mysql

[root@jenkins ~]# yum -y install mysql-server

设置开机启动并启动mysql

[root@jenkins ~]# systemctl enable mysqld
[root@jenkins ~]# systemctl start mysqld
[root@jenkins ~]# systemctl status mysqld

首次安装后,可以通过mysql日志查询默认密码,登录后修改密码即可。

[root@jenkins ~]# cat /var/log/mysqld.log |grep password
2022-01-02T06:48:58.316678Z 1 [Note] A temporary password is generated for root@localhost: e:xa#2U2k+As

e:xa#2U2k+As 就是初始密码
初始密码登录后必须先执行修改密码才能进行其他操作

[root@jenkins ~]# mysql -u root -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 3
Server version: 5.7.36
mysql> use mysql
ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.

#进行其他操作会提示修改密码

mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'Mysql.123';
Query OK, 0 rows affected (0.00 sec)
mysql> set global validate_password_policy=0;
Query OK, 0 rows affected (0.00 sec)
mysql> set global validate_password_length=1;
Query OK, 0 rows affected (0.00 sec)

如果遇到密钥过期

rpm --import https://repo.mysql.com/RPM-GPG-KEY-mysql-2022

原文链接:https://blog.csdn.net/qq_43084874/article/details/122276316

你可能感兴趣的:(linux,jenkins,运维)