[root@one ~]# cd /etc/yum.repos.d/
[root@one yum.repos.d]# ls
CentOS-Stream-AppStream.repo
CentOS-Stream-BaseOS.repo
CentOS-Stream-Debuginfo.repo
CentOS-Stream-Extras-common.repo
CentOS-Stream-Extras.repo
CentOS-Stream-HighAvailability.repo
CentOS-Stream-Media.repo
CentOS-Stream-NFV.repo
CentOS-Stream-PowerTools.repo
CentOS-Stream-RealTime.repo
CentOS-Stream-ResilientStorage.repo
CentOS-Stream-Sources.repo
[root@one ~]# yum clean all //清理一下缓存
0 files removed
[root@one ~]# yum makecache
CentOS Stream 8 - AppStream 4.8 kB/s | 4.4 kB 00:00
CentOS Stream 8 - BaseOS 5.0 kB/s | 3.9 kB 00:00
CentOS Stream 8 - Extras 10 kB/s | 18 kB 00:01
CentOS Stream 8 - Extras comm 3.9 kB/s | 5.2 kB 00:01
Metadata cache created.
[root@one ~]# yum list all|grep mysql //查看
[root@one ~]# rm -rf /etc/yum.repos.d/* //把系统自带的删了
[root@one ~]# yum clean all //清理缓存
27 files removed
[root@one ~]# yum list all
[root@one ~]# cd /etc/yum.repos.d
[root@one yum.repos.d]# ls
[root@one yum.repos.d]# yum list all|grep mysql
[root@one yum.repos.d]# cd
[root@one ~]# rpm -Uvh http://dev.mysql.com/get/mysql57-community-release-el7-10.noarch.rpm //安装yum源
Retrieving http://dev.mysql.com/get/mysql57-community-release-el7-10.noarch.rpm
warning: /var/tmp/rpm-tmp.nLqzTY: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
Verifying... ################################# [100%]
Preparing... ################################# [100%]
Updating / installing...
1:mysql57-community-release-el7-10 ################################# [100%]
[root@one ~]# ls /etc/yum.repos.d/
mysql-community.repo mysql-community-source.repo
[root@one ~]# yum clean all
0 files removed
[root@one ~]# yum makecache
MySQL Connectors Community 24 kB/s | 53 kB 00:02
MySQL Tools Community 60 kB/s | 778 kB 00:13
MySQL 5.7 Community Server 65 kB/s | 2.8 MB 00:43
Metadata cache created.
[root@one ~]# yum list all|grep mysql //过滤一下
mysql57-community-release.noarch el7-10 @System
mysql-community-client.i686 5.7.40-1.el7 mysql57-community
mysql-community-client.x86_64 5.7.40-1.el7 mysql57-community
mysql-community-common.i686 5.7.40-1.el7 mysql57-community
mysql-community-common.x86_64 5.7.40-1.el7 mysql57-community
mysql-community-devel.i686 5.7.40-1.el7 mysql57-community
mysql-community-devel.x86_64 5.7.40-1.el7 mysql57-community
mysql-community-embedded.i686 5.7.40-1.el7 mysql57-community
mysql-community-embedded.x86_64 5.7.40-1.el7 mysql57-community
mysql-community-embedded-compat.i686 5.7.40-1.el7 mysql57-community
mysql-community-embedded-compat.x86_64 5.7.40-1.el7 mysql57-community
mysql-community-embedded-devel.i686 5.7.40-1.el7 mysql57-community
mysql-community-embedded-devel.x86_64 5.7.40-1.el7 mysql57-community
mysql-community-libs.i686 5.7.40-1.el7 mysql57-community
mysql-community-libs.x86_64 5.7.40-1.el7 mysql57-community
mysql-community-libs-compat.i686 5.7.40-1.el7 mysql57-community
mysql-community-libs-compat.x86_64 5.7.40-1.el7 mysql57-community
mysql-community-release.noarch el7-5 mysql-connectors-community
mysql-community-release.noarch el7-5 mysql-tools-community
mysql-community-server.x86_64 5.7.40-1.el7 mysql57-community
mysql-community-test.x86_64 5.7.40-1.el7 mysql57-community
mysql-connector-c++.x86_64 8.0.31-1.el7 mysql-connectors-community
mysql-connector-c++-devel.x86_64 8.0.31-1.el7 mysql-connectors-community
mysql-connector-c++-jdbc.x86_64 8.0.31-1.el7 mysql-connectors-community
mysql-connector-j.noarch 1:8.0.31-1.el7 mysql-connectors-community
mysql-connector-java.noarch 1:8.0.30-1.el7 mysql-connectors-community
mysql-connector-odbc.x86_64 8.0.31-1.el7 mysql-connectors-community
mysql-connector-odbc-setup.x86_64 8.0.31-1.el7 mysql-connectors-community
mysql-connector-python.noarch 2.0.4-1.el7 mysql-connectors-community
mysql-connector-python.x86_64 8.0.23-1.el7 mysql-connectors-community
mysql-connector-python-cext.x86_64 8.0.21-1.el7 mysql-connectors-community
mysql-connector-python3.x86_64 8.0.31-1.el7 mysql-connectors-community
mysql-connector-python3-cext.x86_64 8.0.21-1.el7 mysql-connectors-community
mysql-ref-manual-5.5-en-html-chapter.noarch 1-20170320 mysql57-community
mysql-ref-manual-5.5-en-pdf.noarch 1-20170320 mysql57-community
mysql-ref-manual-5.7-en-html-chapter.noarch 1-20220831 mysql57-community
mysql-ref-manual-5.7-en-pdf.noarch 1-20220831 mysql57-community
mysql-router.x86_64 8.0.12-1.el7 mysql-tools-community
mysql-router-community.x86_64 8.0.31-1.el7 mysql-tools-community
mysql-shell.x86_64 8.0.31-1.el7 mysql-tools-community
mysql-utilities.noarch 1.6.5-1.el7 mysql-tools-community
mysql-utilities-extra.noarch 1.5.6-1.el7 mysql-tools-community
mysql-workbench-community.x86_64 8.0.22-1.el7 mysql-tools-community
[root@one ~]# ls
anaconda-ks.cfg
[root@one ~]# curl -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-vault-8.5.2111.repo
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:--:-- --:--:-100 2495 100 2495 0 0 8372 0 --:--:-- --:--:-- --:--:-- 8372
(curl -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-vault-8.5.2111.repo) //下载阿里云的CentOS 镜像 https://developer.aliyun.com/mirror/centos?spm=a2c6h.13651102.0.0.3e221b11sF8lus
[root@one ~]# sed -i -e '/mirrors.cloud.aliyuncs.com/d' -e '/mirrors.aliyuncs.com/d' /etc/yum.repos.d/CentOS-Base.repo //把云相关的东西删了
[root@one ~]# yum clean all
15 files removed
[root@one ~]# yum makecache
[root@one ~]# cd /etc/yum.repos.d/
[root@one yum.repos.d]# ls
CentOS-Base.repo mysql-community.repo mysql-community-source.repo
[root@one yum.repos.d]# cat mysql-community.repo
[mysql-connectors-community]
name=MySQL Connectors Community
baseurl=http://repo.mysql.com/yum/mysql-connectors-community/el/7/$basearch/
enabled=1
gpgcheck=1
(http://repo.mysql.com/yum/mysql-5.7-community/el/7/x86_64/)
[root@one ~]# yum -y install wget
[root@one ~]# ls
anaconda-ks.cfg
[root@one ~]# cd /usr/src/
[root@one src]# ls
debug kernels
[root@one src]# wget http://repo.mysql.com/yum/mysql-5.7-community/el/7/x86_64/mysql-community-client-5.7.40-1.el7.x86_64.rpm http://repo.mysql.com/yum/mysql-5.7-community/el/7/x86_64/mysql-community-common-5.7.40-1.el7.x86_64.rpm http://repo.mysql.com/yum/mysql-5.7-community/el/7/x86_64/mysql-community-devel-5.7.40-1.el7.x86_64.rpm http://repo.mysql.com/yum/mysql-5.7-community/el/7/x86_64/mysql-community-libs-5.7.40-1.el7.x86_64.rpm http://repo.mysql.com/yum/mysql-5.7-community/el/7/x86_64/mysql-community-server-5.7.40-1.el7.x86_64.rpm
[root@one src]# ls
debug
kernels
mysql-community-client-5.7.40-1.el7.x86_64.rpm
mysql-community-common-5.7.40-1.el7.x86_64.rpm
mysql-community-devel-5.7.40-1.el7.x86_64.rpm
mysql-community-libs-5.7.40-1.el7.x86_64.rpm
mysql-community-server-5.7.40-1.el7.x86_64.rpm
[root@one yum.repos.d]# cd
[root@one ~]# cd /etc/yum.repos.d/
[root@one yum.repos.d]# ls
CentOS-Base.repo mysql-community.repo mysql-community-source.repo
[root@one yum.repos.d]# yum -y install vim
Last metadata expiration check: 0:08:24 ago on Tue 27 Dec 2022 09:15:09 PM CST.
Dependencies resolved.
[root@one yum.repos.d]# ls
CentOS-Base.repo mysql-community.repo mysql-community-source.repo
[root@one yum.repos.d]# vim mysql-community.repo
[root@one yum.repos.d]# cat mysql-community.repo
[mysql57-community]
name=MySQL 5.7 Community Server
baseurl=http://repo.mysql.com/yum/mysql-5.7-community/el/7/x86_64/
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql
[root@one ~]# yum clean all
33 files removed
[root@one ~]# yum makecache
[root@one ~]# cd /usr/src/
[root@one src]# yum -y localinstall *.rpm
[root@one src]# cd
[root@one ~]# systemctl status mysqld //查看一下守护进程
● mysqld.service - MySQL Server
Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; vendor preset>
Active: inactive (dead)
Docs: man:mysqld(8)
http://dev.mysql.com/doc/refman/en/using-systemd.html
[root@one ~]# systemctl disable --now firewalld //把防火墙关了
[root@one ~]# vim /etc/selinux/config
[root@one ~]# cat /etc/selinux/config
SELINUX=disabled
# SELINUXTYPE= can take one of these three values:
[root@one ~]# setenforce 0 //即时生效
[root@one ~]# systemctl start mysqld //临时启动
[root@one ~]# ss -antl //查看端口号
State Recv-Q Send-Q Local Address:Port Peer Address:Port Process
LISTEN 0 128 0.0.0.0:22 0.0.0.0:*
LISTEN 0 128 [::]:22 [::]:*
LISTEN 0 80 *:3306 *:*
[root@one ~]#
[root@one ~]# grep password /var/log/mysqld.log //查看临时密码
2022-12-27T13:44:57.047595Z 1 [Note] A temporary password is generated for root@localhost: #g9ql4#J/y?l
[root@one ~]# mysql -uroot -p'#g9ql4#J/y?l' //借助密码登录
进来了
mysql> set password = password("Aa345678!");
Query OK, 0 rows affected, 1 warning (0.00 sec) //设置密码 大写小写特殊字符八位
[root@one ~]# rpm -qa|grep mysql
mysql57-community-release-el7-10.noarch
mysql-community-common-5.7.40-1.el7.x86_64
mysql-community-libs-5.7.40-1.el7.x86_64
mysql-community-client-5.7.40-1.el7.x86_64
mysql-community-devel-5.7.40-1.el7.x86_64
mysql-community-server-5.7.40-1.el7.x86_64
[root@one ~]# rpm -e mysql57-community-release //干掉
warning: /etc/yum.repos.d/mysql-community.repo saved as /etc/yum.repos.d/mysql-community.repo.rpmsave
[root@one ~]# rpm -qa|grep mysql
mysql-community-common-5.7.40-1.el7.x86_64
mysql-community-libs-5.7.40-1.el7.x86_64
mysql-community-client-5.7.40-1.el7.x86_64
mysql-community-devel-5.7.40-1.el7.x86_64
mysql-community-server-5.7.40-1.el7.x86_64
[root@one ~]# cd /etc/yum.repos.d/
[root@one yum.repos.d]# ls
CentOS-Base.repo mysql-community.repo.rpmsave
[root@one yum.repos.d]# rm -f mysql-community.repo.rpmsave //删掉这个文件
[root@one ~]# mysql_secure_installation //mysql的安全安装
Securing the MySQL server deployment.
Enter password for user root:
The 'validate_password' plugin is installed on the server.
The subsequent steps will run with the existing configuration
of the plugin.
Using existing password for root.
Estimated strength of the password: 100
Change the password for root ? ((Press y|Y for Yes, any other key for No) : n
... skipping.
By default, a MySQL installation has an anonymous user,
allowing anyone to log into MySQL without having to have
a user account created for them. This is intended only for
testing, and to make the installation go a bit smoother.
You should remove them before moving into a production
environment.
Remove anonymous users? (Press y|Y for Yes, any other key for No) : y
Success.
Normally, root should only be allowed to connect from
'localhost'. This ensures that someone cannot guess at
the root password from the network.
Disallow root login remotely? (Press y|Y for Yes, any other key for No) : n
... skipping.
By default, MySQL comes with a database named 'test' that
anyone can access. This is also intended only for testing,
and should be removed before moving into a production
environment.
Remove test database and access to it? (Press y|Y for Yes, any other key for No) : y
- Dropping test database...
Success.
- Removing privileges on test database...
Success.
Reloading the privilege tables will ensure that all changes
made so far will take effect immediately.
Reload privilege tables now? (Press y|Y for Yes, any other key for No) : y
Success.
All done!
http://navicat.com.cn/download/navicat-for-mysql
mysql> grant all on *.* to 'root'@'192.168.198.1' identified by 'Aa345678!'; //授权
Query OK, 0 rows affected, 1 warning (0.00 sec)
mysql> flush privileges; //生效
Query OK, 0 rows affected (0.00 sec)
mysql>
mysql
于 2022-12-28 08:51:41 首次发布