虚拟机中的 centOS 7 系统中 安装MySQL,并用SQLyog实现远程连接
提前须知: FinalShell 的详细用法及软件下载 [FinalShell 的详细用法及软件下载的教程]
(https://blog.csdn.net/weixin_47976194/article/details/126039939?spm=1001.2014.3001.5502)
1、下载wget
[root@localhost ~]# yum -y install wget
[root@localhost ~]# yum -y install mysql57-community-release-el7-8.noarch.rpm`
[root@localhost ~]# yum -y install mysql-community-server
可能会报这个,不要慌,接着往下走:
mysql-community-libs-compat-5.7.39-1.el7.x86_64.rpm 的公钥尚未安装
失败的软件包是:mysql-community-libs-compat-5.7.39-1.el7.x86_64
GPG 密钥配置为:file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql
[root@localhost ~]# rpm --import https://repo.mysql.com/RPM-GPG-KEY-mysql
-2022
[root@localhost ~]# yum -y install mysql-community-server
//启动服务
[root@localhost ~]# systemctl start mysqld.service
//查看服务是否启动成功
[root@localhost ~]# systemctl status mysqld
//获得root用户的临时密码
[root@localhost ~]# cat /var/log/mysqld.log | grep password
2022-08-03T02:02:19.943915Z 1
[Note] A temporary password is
generated for
**root@localhost: FGmiyKVJ8k+_**
//登录root用户
[root@localhost ~]# mysql -uroot -p
Enter password:
mysql> alter user 'root'@'localhost' identified by 'H@ppy2022';
Query OK, 0 rows affected (0.00 sec
mysql> create user 'root'@'%' identified by 'Hh123456';
Query OK, 0 rows affected (0.00 sec)
mysql> grant all privileges on *.* to 'root'@'%' with grant option;
Query OK, 0 rows affected (0.00 sec)
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
[root@localhost ~]# mysql -uroot -pH@ppy2022
//关闭防火墙
[root@localhost ~]# systemctl stop firewalld
[root@localhost ~]# systemctl disable firewalld
[root@localhost ~]# mysql -uroot -pH@ppy2022
//关闭防火墙
[root@localhost ~]# systemctl stop firewalld.service
[root@localhost ~]# systemctl disable firewalld.service
[root@localhost ~]# systemctl start firewalld.service
[root@localhost ~]# firewall-cmd --zone=public --add-port=3306/tcp --perm
anent
success
[root@localhost ~]# firewall-cmd --reload
success
[root@localhost ~]# firewall-cmd --list-port
3306/tcp
//开启开机后MySQL服务自行启动
[root@localhost ~]# systemctl enable mysqld.service
//关闭MySQL服务自行启动(可直接略过)
[root@localhost ~]# systemctl disable mysqld.service