yum update -y
sudo yum install -y wget
wget https://dev.mysql.com/get/mysql80-community-release-el7-3.noarch.rpm
sudo yum localinstall mysql80-community-release-el7-3.noarch.rpm
sudo yum install -y yum-utils
yum repolist enabled | grep "mysql.*-community.*"
sudo yum-config-manager --disable mysql80-community
sudo yum-config-manager --enable mysql57-community
yum repolist enabled | grep mysql
安装mysql:
sudo yum install -y mysql-community-server
这一步报错了
mysql-community-server-5.7.44-1.el7.x86_64.rpm 的公钥尚未安装
失败的软件包是:mysql-community-server-5.7.44-1.el7.x86_64
GPG 密钥配置为:file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql
rpm --import https://repo.mysql.com/RPM-GPG-KEY-mysql-2022
执行后,再次安装mysql,就可以了。
启动mysql
sudo service mysqld start
sudo service mysqld status
从 MySQL 5.7 开始,mysql 安装之后,会默认随机生成一个临时密码,因此登录之后需要修改密码
查看生成的初始密码:
sudo grep 'temporary password' /var/log/mysqld.log
使用初始密码进行登录:
mysql -u root -p
设置新密码
mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'MyNewPass4!';
设置远程登录权限,密码就是上面的新密码
mysql> GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'yourNewPassword' WITH GRANT OPTION;
刷新权限
mysql> FLUSH PRIVILEGES;
密码设置之后安装即完成。
mysql开机启动命令:
mysql> exit
就可退出
systemctl enable mysqld
mysql的配置文件:
/etc/my.cnf
防火墙开放3306端口,外面用工具连接mysql:
[root@localhost etc]# firewall-cmd --zone=public --permanent --add-port=3306/tcp
success
[root@localhost etc]# firewall-cmd --reload
success
[root@localhost etc]#
放开之前
放开之后
至此,工具也能连接mysql了。
供后面安装artifactory使用