MySQL安装部署

安装 MySQL 官方 YUM 仓库:

bash 复制代码
[root@localhost ~]# wget https://dev.mysql.com/get/mysql80-community-release-el7-3.noarch.rpm
--2024-12-02 16:14:09--  https://dev.mysql.com/get/mysql80-community-release-el7-3.noarch.rpm
Resolving dev.mysql.com (dev.mysql.com)... 23.52.218.134, 2600:1417:4400:89a::2e31, 2600:1417:4400:8ac::2e31
Connecting to dev.mysql.com (dev.mysql.com)|23.52.218.134|:443... connected.
HTTP request sent, awaiting response... 302 Moved Temporarily
Location: https://repo.mysql.com//mysql80-community-release-el7-3.noarch.rpm [following]
--2024-12-02 16:14:10--  https://repo.mysql.com//mysql80-community-release-el7-3.noarch.rpm
Resolving repo.mysql.com (repo.mysql.com)... 2.19.153.220, 2600:1417:4400:e8c::1d68, 2600:1417:4400:e84::1d68
Connecting to repo.mysql.com (repo.mysql.com)|2.19.153.220|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 26024 (25K) [application/x-redhat-package-manager]
Saving to: 'mysql80-community-release-el7-3.noarch.rpm'

mysql80-community-rel 100%[=========================>]  25.41K   125KB/s    in 0.2s    

2024-12-02 16:14:11 (125 KB/s) - 'mysql80-community-release-el7-3.noarch.rpm' saved [26024/26024]

[root@localhost ~]# 
[root@localhost ~]# 
[root@localhost ~]# ll
total 32
-rw-------. 1 root root   789 Dec  2  2024 anaconda-ks.cfg
-rw-r--r--. 1 root root 26024 Apr 25  2019 mysql80-community-release-el7-3.noarch.rpm
[root@localhost ~]# rpm -ivh mysql80-community-release-el7-3.noarch.rpm 

安装MySQL服务

bash 复制代码
[root@localhost ~]# sudo yum install mysql-server

启动 MySQL 服务:

bash 复制代码
[root@localhost ~]# sudo systemctl start mysqld
[root@localhost ~]# sudo systemctl status mysqld
● mysqld.service - MySQL 8.0 database server
     Loaded: loaded (/usr/lib/systemd/system/mysqld.service; disabled; vendor preset: d>
     Active: active (running) since Mon 2024-12-02 16:16:40 CST; 9s ago
    Process: 2507 ExecStartPre=/usr/libexec/mysql-check-socket (code=exited, status=0/S>
    Process: 2530 ExecStartPre=/usr/libexec/mysql-prepare-db-dir mysqld.service (code=e>
   Main PID: 2605 (mysqld)
     Status: "Server is operational"
      Tasks: 38 (limit: 21409)
     Memory: 461.6M
     CGroup: /system.slice/mysqld.service
             └─ 2605 /usr/libexec/mysqld --basedir=/usr

Dec 02 16:16:24 localhost.localdomain systemd[1]: Starting MySQL 8.0 database server...
Dec 02 16:16:25 localhost.localdomain mysql-prepare-db-dir[2530]: Initializing MySQL da>
Dec 02 16:16:40 localhost.localdomain systemd[1]: Started MySQL 8.0 database server.

查看MySQL初始密码

bash 复制代码
[root@localhost ~]# sudo grep 'temporary password' /var/log/mysqld.log

通常初次安装点回车就会进入MySQL

bash 复制代码
[root@localhost ~]# mysql -u root -p
Enter password: 
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)
[root@localhost ~]# sudo grep 'temporary password' /var/log/mysqld.log
grep: /var/log/mysqld.log: No such file or directory
[root@localhost ~]# mysql -u root -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 11
Server version: 8.0.40 Source distribution

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> 

修改秘密

bash 复制代码
mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'Wyxbuke00.';
Query OK, 0 rows affected (0.01 sec)
相关推荐
Lalolander2 小时前
2024信创数据库TOP30之华为Gauss DB
大数据·数据库·科技·华为·系统架构
莳花微语3 小时前
Oracle 11G DataGuard GAP 修复过程(通过主库scn增备恢复)
数据库·oracle
petaexpress3 小时前
云原生和数据库哪个好一些?
数据库·云原生·云原生和数据库哪个好·云原生和数据库
Cristiano永远是goat4 小时前
数据库原理-期末复习基础知识第二弹
数据库
MXsoft6185 小时前
智能运维视角下的网络设备监测与数据分析
大数据·运维·数据库
冧轩在努力5 小时前
redis的应用--分布式锁
数据库·redis·分布式
2021-5-55 小时前
利用 Redis 与 Lua 脚本解决秒杀系统中的高并发与库存超卖问题
数据库·redis·lua
都要好好的O5 小时前
2.mysql 中一条更新语句的执行流程是怎样的呢?
数据库·mysql
夏子曦6 小时前
Redis——主从复制原理
数据库·redis·缓存
zxrhhm6 小时前
SQLServer中使用ISNULL替换为指定的替换值
数据库·sqlserver