三种安装方式
tar -xf mysql-5.7.37-linux-glibc2.12-x86_64.tar.gz
[root@sc-mysql opt]# tar -xf mysql-5.7.37-linux-glibc2.12-x86_64.tar.gz
[root@sc-mysql opt]# ls
apache-zookeeper-3.6.3-bin kafka_2.12-2.8.1.tgz
apache-zookeeper-3.6.3-bin.tar.gz mysql-5.7.37-linux-glibc2.12-x86_64
kafka_2.12-2.8.1 mysql-5.7.37-linux-glibc2.12-x86_64.tar.gz
上面是解压压缩包
1.仓库安装
[root@localhost ~]# cat /etc/redhat-release
Red Hat Enterprise Linux release 9.1 (Plow)
[root@localhost ~]# rpm -ivh https://repo.mysql.com//mysql80-community-release-el9-1.noarch.rpm
[root@localhost ~]# dnf install mysql-server -y
[root@localhost ~]# rpm -qa | grep mysql
mysql80-community-release-el9-1.noarch
mysql-community-common-8.0.32-1.el9.x86_64
mysql-community-client-plugins-8.0.32-1.el9.x86_64
mysql-community-libs-8.0.32-1.el9.x86_64
mysql-community-client-8.0.32-1.el9.x86_64
mysql-community-icu-data-files-8.0.32-1.el9.x86_64
mysql-community-server-8.0.32-1.el9.x86_64
[root@localhost ~]# systemctl start mysqld
[root@localhost ~]# systemctl status mysqld
[root@localhost ~]# grep 'temporary password' /var/log/mysqld.log
[root@localhost ~]# mysql -uroot -p
mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'Admin123!';
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| sys |
+--------------------+
4 rows in set (0.00 sec)
卸载
[root@localhost ~]# dnf remove mysql-server -y
[root@localhost ~]# dnf remove mysql80-community-release -y
[root@localhost ~]# rpm -qa | grep mysql
[root@localhost ~]# rm -rf /var/lib/mysql/ /var/log/mysqld.log
本地安装:
[root@localhost mysql]# wget https://cdn.mysql.com//Downloads/MySQL-8.0/mysql-8.0.32-1.el9.x86_64.rpm-bundle.tar
[root@localhost mysql]# tar xvf mysql-8.0.32-1.el9.x86_64.rpm-bundle.tar
[root@localhost mysql]# dnf localinstall mysql-community-server-8.0.32-1.el9.x86_64.rpm \
> mysql-community-client-8.0.32-1.el9.x86_64.rpm \
> mysql-community-common-8.0.32-1.el9.x86_64.rpm \
> mysql-community-icu-data-files-8.0.32-1.el9.x86_64.rpm \
> mysql-community-client-plugins-8.0.32-1.el9.x86_64.rpm \
> mysql-community-libs-8.0.32-1.el9.x86_64.rpm
[root@localhost mysql]# systemctl start mysqld
[root@localhost mysql]# systemctl status mysqld
[root@localhost mysql]# grep 'temporary password' /var/log/mysqld.log
[root@localhost ~]# mysql -uroot -p
Enter password:
mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'Admin123!';
mysql> show databases;
mysql> exit
root@(none) 12:03 mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| sys |
+--------------------+
4 rows in set (0.00 sec)
上面是查看数据库中有哪些数据库