mysql是目前主流的数据库之一,下面开始介绍详细的安装操作流程与步骤以及出现的问题与解决方案。,开始吧~~~~
- 下载Mysql安装包
- 安装
- 相关配置
一、下载MYSQL安装包
下载地址:https://dev.mysql.com/downloads/mysql/根据自己的系统版本下载相应的包,我这边选的是 Red Hat Enterprise Liunx / Oracle Linux -- >Red Hat Enterprise Liunx 7/ Oracle Linux7(x86,64-bit)
共需下载4份文件:
mysql-community-libs-8.0.29-1.el7.x86_64.rpm
mysql-community-common-8.0.29-1.el7.x86_64.rpm
mysql-community-server-8.0.29-1.el7.x86_64.rpm
mysql-community-client-8.0.29-1.el7.x86_64.rpm
二、MYSQL详细安装
上传到Liunx服务器,顺序执行。命令如下。
### 检查是否存在 rpm -qa|grep mariadb ### 删除mariadb rpm -e --nodeps mariadb-libs-5.5.56-2.el7.x86_64
### 第1步 rpm -ivh mysql-community-common-8.0.29-1.el7.x86_64.rpm ### 第2步 rpm -ivh mysql-community-libs-8.0.29-1.el7.x86_64.rpm --force --nodeps ### 第3步 rpm -ivh mysql-community-client-8.0.29-1.el7.x86_64.rpm --force --nodeps ### 第4步 rpm -ivh mysql-community-server-8.0.29-1.el7.x86_64.rpm --force --nodeps =======================================成功截图执行=================================== [root@lcndc2appdbts01 mysql]# rpm -ivh mysql-community-common-8.0.29-1.el7.x86_64.rpm warning: mysql-community-common-8.0.29-1.el7.x86_64.rpm: Header V4 RSA/SHA256 Signature, key ID 3a79bd29: NOKEY Preparing... ######################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################## [100%] Updating / installing... 1:mysql-community-common-8.0.29-1.e######################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################## [100%] [root@lcndc2appdbts01 mysql]# rpm -ivh mysql-community-libs-8.0.29-1.el7.x86_64.rpm warning: mysql-community-libs-8.0.29-1.el7.x86_64.rpm: Header V4 RSA/SHA256 Signature, key ID 3a79bd29: NOKEY error: Failed dependencies: mysql-community-client-plugins = 8.0.29-1.el7 is needed by mysql-community-libs-8.0.29-1.el7.x86_64 [root@lcndc2appdbts01 mysql]# rpm -ivh mysql-community-libs-8.0.29-1.el7.x86_64.rpm --force --nodeps warning: mysql-community-libs-8.0.29-1.el7.x86_64.rpm: Header V4 RSA/SHA256 Signature, key ID 3a79bd29: NOKEY Preparing... ######################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################## [100%] Updating / installing... 1:mysql-community-libs-8.0.29-1.el############################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################### [100%] [root@lcndc2appdbts01 mysql]# rpm -ivh mysql-community-client-8.0.29-1.el7.x86_64.rpm --force --nodeps warning: mysql-community-client-8.0.29-1.el7.x86_64.rpm: Header V4 RSA/SHA256 Signature, key ID 3a79bd29: NOKEY Preparing... ###################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################### [100%] Updating / installing... 1:mysql-community-client-8.0.29-1.e###################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################### [100%] [root@lcndc2appdbts01 mysql]# rpm -qa | grep mysql mysql-community-client-8.0.29-1.el7.x86_64 mysql-community-common-8.0.29-1.el7.x86_64 mysql-community-libs-8.0.29-1.el7.x86_64 [root@lcndc2appdbts01 mysql]# rpm -ivh mysql-community-server-8.0.29-1.el7.x86_64.rpm --force --nodeps warning: mysql-community-server-8.0.29-1.el7.x86_64.rpm: Header V4 RSA/SHA256 Signature, key ID 3a79bd29: NOKEY Preparing... ###################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################### [100%] Updating / installing... 1:mysql-community-server-8.0.29-1.e###################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################### [100%]
[root@lcndc2appdbts01 mysql]# service mysqld start Redirecting to /bin/systemctl start mysqld.service Job for mysqld.service failed because the control process exited with error code. See "systemctl status mysqld.service" and "journalctl -xe" for details. =================================解决方式================================= 因为下载的MYSQLliunx版本是8.0版本的。导致这个问题。导致这个问题。 重新下载liunx7.0版本正常。 =================================成功================================= [root@lcndc2appdbts01 data]# service mysqld start Redirecting to /bin/systemctl start mysqld.service [root@lcndc2appdbts01 data]# ps -ef | grep mysql mysql 60988 1 7 16:49 ? 00:00:00 /usr/sbin/mysqld root 61038 60734 0 16:49 pts/0 00:00:00 grep --color=automysql
三、相关配置
1. 设置临时密码
### 获取临时密码
[root@lcndc2appdbts01 data]# grep 'temporary password' /var/log/mysqld.log
2022-07-21T08:49:02.218250Z 6 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: JwN6)jXoxUtJ
临时密码:JwN6)jXoxUtJ
2. 使用临时密码登录
[root@lcndc2appdbts01 data]# sudo mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 8
Server version: 8.0.29
Copyright (c) 2000, 2022, 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>
3. 设置新密码与远程登录
### 修改临时密码,也可以不修改
alter user 'root'@'localhost' identified by '1oK3aH&52a1m8p;$fE';
Query OK, 0 rows affected (0.01 sec)
### 设置远程可访问
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> select user,host from user; -- 查询当前状态
+------------------+-----------+
| user | host |
+------------------+-----------+
| mysql.infoschema | localhost |
| mysql.session | localhost |
| mysql.sys | localhost |
| root | localhost |
+------------------+-----------+
4 rows in set (0.00 sec)
mysql> update user set host="%" where user="root"; -- 修改可远程访问
Query OK, 1 row affected (0.00 sec)
Rows matched: 1 Changed: 1 Warnings: 0
mysql> select user,host from user;
+------------------+-----------+
| user | host |
+------------------+-----------+
| root | % |
| mysql.infoschema | localhost |
| mysql.session | localhost |
| mysql.sys | localhost |
+------------------+-----------+
4 rows in set (0.00 sec)
4. 刷新授权()
flush privileges;
5. 使用Navicat或者其他工具验证
### 核心
大家安装的时候,一定要先看好自己的服务器系统版本,以免下错安装包造成安装过程中出现这种乱七八糟的问题。切记!!!