目录
🧀写在前面
🧀前提条件
🧀安装MySQL8.0
🧀MySQL管理
🦐博客主页:大虾好吃吗的博客
🦐MySQL专栏:MySQL专栏地址
写在前面
MySQL是一种开源的关系型数据库管理系统(RDBMS),它是由瑞典公司MySQL AB开发,并在2008年被甲骨文公司(Oracle Corporation)收购。MySQL是目前最流行的关系型数据库之一,被广泛应用于各种网站、应用程序和企业级系统中。
MySQL官方下载地址:官网下载地址
MySQL参考手册:MySQL 8.0 参考手册
根据下图下载安装包
前提条件
开启一台CentOS7.9服务器,做好安装MySQL前的准备。
1、关闭防火墙
[root@mysql11 /]# systemctl stop firewalld
[root@mysql11 /]# systemctl disable firewalld
2、关闭selinux
[root@mysql11 /]# setenforce 0
[root@mysql11 /]# sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/config
3、上传安装包到服务器
一般CRT工具自带上传下载选项,如果没有则下载lrzsz,我下面命令行显示的包已经上传成功。
[root@mysql11 /]# ls
bin dev home lib64 mnt opt root sbin sys usr
boot etc lib media mysql-8.0.33-1.el7.x86_64.rpm-bundle.tar proc run srv tmp var
4、解压tar包
创建一个目录,在该目录下解压安装包后得到多个rpm包,至此,准备工作完成,下面开始安装。
[root@mysql11 /]# mkdir /mysql
[root@mysql11 /]# mv mysql-8.0.33-1.el7.x86_64.rpm-bundle.tar /mysql
[root@mysql11 /]# cd /mysql
[root@mysql11 mysql]# tar xf mysql-8.0.33-1.el7.x86_64.rpm-bundle.tar
[root@mysql11 mysql]# ls
mysql-8.0.33-1.el7.x86_64.rpm-bundle.tar
mysql-community-client-8.0.33-1.el7.x86_64.rpm
mysql-community-client-plugins-8.0.33-1.el7.x86_64.rpm
mysql-community-common-8.0.33-1.el7.x86_64.rpm
mysql-community-debuginfo-8.0.33-1.el7.x86_64.rpm
mysql-community-devel-8.0.33-1.el7.x86_64.rpm
mysql-community-embedded-compat-8.0.33-1.el7.x86_64.rpm
mysql-community-icu-data-files-8.0.33-1.el7.x86_64.rpm
mysql-community-libs-8.0.33-1.el7.x86_64.rpm
mysql-community-libs-compat-8.0.33-1.el7.x86_64.rpm
mysql-community-server-8.0.33-1.el7.x86_64.rpm
mysql-community-server-debug-8.0.33-1.el7.x86_64.rpm
mysql-community-test-8.0.33-1.el7.x86_64.rpm
安装MySQL8.0
1、安装openssl-devel依赖
[root@mysql11 mysql]# yum -y install openssl-devel
# 省略安装部分
2、安装mysql,注意:有的包需要依赖,加上nodeps参数不检查依赖关系;force表示强制安装下面为了更详细的表示,rpm包全都单独安装(熟悉的可以用rpm -ivh mysql-community-* --nodeps --force安装)。
[root@mysql11 mysql]# rpm -ivh mysql-community-common-8.0.33-1.el7.x86_64.rpm --nodeps --force
[root@mysql11 mysql]# rpm -ivh mysql-community-client-plugins-8.0.33-1.el7.x86_64.rpm --nodeps --force
[root@mysql11 mysql]# rpm -ivh mysql-community-libs-8.0.33-1.el7.x86_64.rpm --nodeps --force
[root@mysql11 mysql]# rpm -ivh mysql-community-libs-compat-8.0.33-1.el7.x86_64.rpm --nodeps --force
[root@mysql11 mysql]# rpm -ivh mysql-community-devel-8.0.33-1.el7.x86_64.rpm --nodeps --force
[root@mysql11 mysql]# rpm -ivh mysql-community-client-8.0.33-1.el7.x86_64.rpm --nodeps --force
[root@mysql11 mysql]# rpm -ivh mysql-community-icu-data-files-8.0.33-1.el7.x86_64.rpm --nodeps --force
[root@mysql11 mysql]# rpm -ivh mysql-community-server-8.0.33-1.el7.x86_64.rpm --nodeps --force
3、mysql管理
[root@mysql11 mysql]# systemctl start mysqld #启动
[root@mysql11 mysql]# systemctl restart mysqld #重启
[root@mysql11 mysql]# systemctl status mysqld #查看状态
[root@mysql11 mysql]# systemctl stop mysqld #关闭
4、查看端口
使用上面的启动命令启动后,查看端口,如果没有查看mysql是否启动。
[root@mysql11 mysql]# ss -anptl | grep 3306
LISTEN 0 70 [::]:33060 [::]:* users:(("mysqld",pid=4687,fd=21))
LISTEN 0 128 [::]:3306 [::]:* users:(("mysqld",pid=4687,fd=23))
MySQL管理
1、测试登录
默认情况下没有密码登录不上去,下面尝试一下(报错正常)。
[root@mysql11 mysql]# mysql
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)
2、查看初始密码
默认情况下密码在/var/log/mysqld.log,通过查看日志找到初始密码。初始密码在冒号后面 例如我的密码是 9CHE4jqcpu)1
[root@mysql11 mysql]# grep password /var/log/mysqld.log
2023-07-19T23:16:31.478216Z 6 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: 9CHE4jqcpu)1
3、登录MySQL
注意下面第二行位置输入密码,密码是不交互(不显示),输入正确即可登录。
[root@mysql11 mysql]# mysql -uroot -p
Enter password: #输入密码
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 9
Server version: 8.0.33
Copyright (c) 2000, 2023, Oracle and/or its affiliates.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql>
4、修改密码并测试登录文章来源:https://www.toymoban.com/news/detail-614972.html
mysql> alter user 'root'@'localhost' identified by '123.daxia.COM'; #密码需要符合密码复杂性
Query OK, 0 rows affected (0.00 sec)
mysql> exit #退出
Bye
[root@mysql11 mysql]# mysql -uroot -p123.daxia.COM #密码设置在-p参数后添加能有空格
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 13
Server version: 8.0.33 MySQL Community Server - GPL
Copyright (c) 2000, 2023, Oracle and/or its affiliates.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> show databases; #登录成功后查看库
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| sys |
+--------------------+
4 rows in set (0.01 sec)
扫描下方二维码关注公众号抽奖哦,每期送书活动都在公众号进行(公开、公正、透明)文章来源地址https://www.toymoban.com/news/detail-614972.html
到了这里,关于CentOS7.9安装MySQL8.0的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!