安装MySQL8数据库
https://www.518cn.com 发布时间:2025-03-18 22:32 作者:网络
摘要:安装MySQL8 MySQL Community Server 社区版本,开源免费,自由下载,但不提供官方技术支持,适用于大多数普通用户。 MySQL Enterprise Edition 企业版本,需付费,不能在线下载,可以试用30天。提
安装MySQL8
MySQL Community Server 社区版本,开源免费,自由下载,但不提供官方技术支持,适用于大多数普通用户。
MySQL Enterprise Edition 企业版本,需付费,不能在线下载,可以试用30天。提供了更多的功能和更完备的技术支持,更适合于对数据库的功能和可靠性要求较高的企业客户。
MySQL Cluster 集群版,开源免费。用于架设集群服务器,可将几个MySQL Server封装成一个Server。需要在社区版或企业版的基础上使用。
MySQL Cluster CGE 高级集群版,需付费。
安装 mysql yum源
[root@web ~]# wget https://repo.mysql.com//mysql84-community-release-el9-1.noarch.rpm
[root@web ~]# yum install ./mysql84-community-release-el9-1.noarch.rpm
[root@web ~]#
安装成功后,查看MySQL版本:
[root@web ~]# yum repolist all | grep mysql
mysql-8.4-lts-community MySQL 8.4 LTS Community Server 启用
mysql-8.4-lts-community-debuginfo MySQL 8.4 LTS Community Server 禁用
mysql-8.4-lts-community-source MySQL 8.4 LTS Community Server 禁用
mysql-cluster-8.0-community MySQL Cluster 8.0 Community 禁用
mysql-cluster-8.0-community-debuginfo MySQL Cluster 8.0 Community - 禁用
mysql-cluster-8.0-community-source MySQL Cluster 8.0 Community - 禁用
mysql-cluster-8.4-lts-community MySQL Cluster 8.4 LTS Communit 禁用
mysql-cluster-8.4-lts-community-debuginfo MySQL Cluster 8.4 LTS Communit 禁用
mysql-cluster-8.4-lts-community-source MySQL Cluster 8.4 LTS Communit 禁用
mysql-cluster-innovation-community MySQL Cluster Innovation Relea 禁用
mysql-cluster-innovation-community-debuginfo MySQL Cluster Innovation Relea 禁用
mysql-cluster-innovation-community-source MySQL Cluster Innovation Relea 禁用
mysql-connectors-community MySQL Connectors Community 启用
mysql-connectors-community-debuginfo MySQL Connectors Community - D 禁用
mysql-connectors-community-source MySQL Connectors Community - S 禁用
mysql-innovation-community MySQL Innovation Release Commu 禁用
mysql-innovation-community-debuginfo MySQL Innovation Release Commu 禁用
mysql-innovation-community-source MySQL Innovation Release Commu 禁用
mysql-tools-8.4-lts-community MySQL Tools 8.4 LTS Community 启用
mysql-tools-8.4-lts-community-debuginfo MySQL Tools 8.4 LTS Community 禁用
mysql-tools-8.4-lts-community-source MySQL Tools 8.4 LTS Community 禁用
mysql-tools-community MySQL Tools Community 禁用
mysql-tools-community-debuginfo MySQL Tools Community - Debugi 禁用
mysql-tools-community-source MySQL Tools Community - Source 禁用
mysql-tools-innovation-community MySQL Tools Innovation Communi 禁用
mysql-tools-innovation-community-debuginfo MySQL Tools Innovation Communi 禁用
mysql-tools-innovation-community-source MySQL Tools Innovation Communi 禁用
mysql80-community MySQL 8.0 Community Server 禁用
mysql80-community-debuginfo MySQL 8.0 Community Server - D 禁用
mysql80-community-source MySQL 8.0 Community Server - S 禁用
[root@web ~]#
安装MySQL
[root@web ~]# yum install mysql-community-server
启动MySQL服务
[root@web ~]# systemctl start mysqld
确认MySQL正常启动
[root@web ~]# systemctl status mysqld
设置MySQL开机自启动
[root@web ~]# systemctl enable mysqld
查看生成 MySQL root用户临时密码:
[root@web ~]# grep 'temporary password' /var/log/mysqld.log
修改root用户密码
# 登录数据库
[root@web ~]# mysql -uroot -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or g.
Your MySQL connection id is 8
Server version: 8.4.3
Copyright (c) 2000, 2024, 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>
mysql>
mysql>
# 修改root密码
mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'Password@2024';
Query OK, 0 rows affected (0.01 sec)
mysql>
设置远程登录
# 查看默认库
mysql> SHOW DATABASES;
--------------------
| Database |
--------------------
| information_schema |
| mysql |
| performance_schema |
| sys |
--------------------
4 rows in set (0.00 sec)
mysql>
# 选择使用mysql库
mysql> use mysql;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Database changed
mysql>
# 查询用户表
mysql> select host, user, authentication_string, plugin from user;
----------- ------------------ ------------------------------------------------------------------------ -----------------------
| host | user | authentication_string | plugin |
----------- ------------------ ------------------------------------------------------------------------ -----------------------
| localhost | mysql.infoschema | $A$005$THISISACOMBINATIONOFINVALIDSALTANDPASSWORDTHATMUSTNEVERBRBEUSED | caching_sha2_password |
| localhost | mysql.session | $A$005$THISISACOMBINATIONOFINVALIDSALTANDPASSWORDTHATMUSTNEVERBRBEUSED | caching_sha2_password |
| localhost | mysql.sys | $A$005$THISISACOMBINATIONOFINVALIDSALTANDPASSWORDTHATMUSTNEVERBRBEUSED | caching_sha2_password |
| localhost | root | $A$005$@c%qYYPJ~F-qAGZDHB6e7/1eEIz5VmK2O87RS12HBQpiPrZ7nVNqHX/D3 | caching_sha2_password |
----------- ------------------ ------------------------------------------------------------------------ -----------------------
4 rows in set (0.00 sec)
mysql>
# 修改root的授权
mysql> update user set host='%' where user='root';
Query OK, 1 row affected (0.00 sec)
Rows matched: 1 Changed: 1 Warnings: 0
mysql>
# 需要执行俩次
mysql> Grant all privileges on *.* to 'root'@'%';
ERROR 1410 (42000): You are not allowed to create a user with GRANT
mysql>
mysql> Grant all privileges on *.* to 'root'@'%';
Query OK, 0 rows affected (0.01 sec)
mysql>
# 刷新权限
mysql> flush privileges;
Query OK, 0 rows affected (0.01 sec)
mysql>
mysql>
# 再次查看用户表
mysql> select host, user, authentication_string, plugin from user;
----------- ------------------ ------------------------------------------------------------------------ -----------------------
| host | user | authentication_string | plugin |
----------- ------------------ ------------------------------------------------------------------------ -----------------------
| % | root | $A$005$@c%qYYPJ~F-qAGZDHB6e7/1eEIz5VmK2O87RS12HBQpiPrZ7nVNqHX/D3 | caching_sha2_password |
| localhost | mysql.infoschema | $A$005$THISISACOMBINATIONOFINVALIDSALTANDPASSWORDTHATMUSTNEVERBRBEUSED | caching_sha2_password |
| localhost | mysql.session | $A$005$THISISACOMBINATIONOFINVALIDSALTANDPASSWORDTHATMUSTNEVERBRBEUSED | caching_sha2_password |
| localhost | mysql.sys | $A$005$THISISACOMBINATIONOFINVALIDSALTANDPASSWORDTHATMUSTNEVERBRBEUSED | caching_sha2_password |
----------- ------------------ ------------------------------------------------------------------------ -----------------------
4 rows in set (0.00 sec)
mysql>
测试连接
# 使用其他主机进行登录数据库
[root@k8s-master01 ~]# mysql -u root -p -h 192.168.1.130
Enter password:
Welcome to the MySQL monitor. Commands end with ; or g.
Your MySQL connection id is 8
Server version: 8.4.3 MySQL Community Server - GPL
Copyright (c) 2000, 2024, 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>
mysql>
mysql>
关于
https://www.oiox.cn/
https://www.oiox.cn/index.php/start-page.html
CSDN、GitHub、51CTO、知乎、开源中国、思否、掘金、简书、华为云、阿里云、腾讯云、哔哩哔哩、今日头条、新浪微博、个人博客
全网可搜《小陈运维》
文章主要发布于微信公众号
相关文章
- 优化GreatSQL日志文件空间占用 GreatSQL对于日志文件磁盘空间占用,做了一些优化,对于binlog、...03-18
- "数据约束条件" date: 2022-11-24T21:24:31 08:00 draft: false MySQL字段约束条件 无符号, 零填充...03-18
【GreatSQL优化器-16】INDEX_SKIP_SCAN
【GreatSQL优化器-16】INDEX_SKIP_SCAN 一、INDEX_SKIP_SCAN介绍 GreatSQL 优化器的索引跳跃扫描(Index Ski...03-18- MySQL 是一个非常流行的开源关系数据库管理系统,在各种应用场景中都得到了广泛的应用。随...03-18
- 🤖 DB-GPT 是一个开源的 AI 原生数据应用程序开发框架,具有 AWEL(代理工作流表达式语...03-18
GreatSQL 8.0.32-27 GA (2025-3-10)
GreatSQL 8.0.32-27 GA (2025-3-10) 版本信息 发布时间:2025年3月10日 版本号:8.0.32-27, Revision aa66a38591...03-18- 6. MySQL 索引的数据结构(详细说明) @目录6. MySQL 索引的数据结构(详细说明)1. 为什么使用索引2...03-18
- @Override @Transactional(rollbackFor = Exception.class) public void batchInsertDeviceData(IotMsgNotifyData iotMsgNotifyDa...03-18
- 个人Qt项目总结——数据库查询断言问题 问题: 当我使用MySQL数据库的查询操作时, 如果查询...03-18
- MySQL 是一种广泛使用的关系数据库管理系统,MySQL 8 是其最新的主要版本,结合了出色的性能和...03-18
最新评论