docs: 补充多篇技术博客内容

1. 为Linux服务安装文档新增RHEL/CentOS官方仓库安装Nginx步骤
2. 新增Windows Server开发驱动器完整教程
3. 重构MySQL文档:将原有安装内容拆分归类,新增MySQL配置模块、Windows绿色版安装细节、Linux客户端安装卸载完整流程
This commit is contained in:
2026-06-03 11:15:20 +08:00
parent 7e38841220
commit bc0ba78c8b
3 changed files with 604 additions and 221 deletions
+229 -220
View File
@@ -7,6 +7,235 @@ tags: [MySQL, 数据库, SQL, 备份]
categories: [数据库, MySQL]
---
# MySQL 配置
`my.ini` 或 `my.cnf` 配置
```ini
```
# Windows 下安装 绿色版
先下载[MySQL :: Download MySQL Community Server](https://dev.mysql.com/downloads/mysql/)
![image-20231007124717167](https://markdownhexo.oss-cn-hangzhou.aliyuncs.com/img/image-20231007124717167.png)
1. 解压下载好的压缩包
![在这里插入图片描述](https://rustfs.wenyongdalucky.club:443/hexo/20210120105901505.png)
2. 解压后得到
![在这里插入图片描述](https://rustfs.wenyongdalucky.club:443/hexo/20210120105247435.png)
3. 新建一个 `my.ini`文件
![在这里插入图片描述](https://rustfs.wenyongdalucky.club:443/hexo/20210120110525427.png)
4. 解压后的mysql根目录下没有my.ini文件,自己去网上找一份就可或者使用我在后面给出的代码。.ini文件会在初始化mysql中用到
```ini
# For advice on how to change settings please see
# http=//dev.mysql.com/doc/refman/5.7/en/server-configuration-defaults.html
# *** DO NOT EDIT THIS FILE. It's a template which will be copied to the
# *** default location during install, and will be replaced if you
# *** upgrade to a newer version of MySQL.
[client]
port = 3306
default-character-set = utf8
[mysqld]
# Remove leading # and set to the amount of RAM for the most important data
# cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%.
# innodb_buffer_pool_size = 128M
# Remove leading # to turn on a very important data integrity option= logging
# changes to the binary log between backups.
# log_bin
port = 3306
# These are commonly set, remove the # and set as required.
basedir="D:\app\mysql-5.7.43-winx64"
datadir="D:\app\mysql-5.7.43-winx64\data"
# server_id = .....
character_set_server = utf8
# Remove leading # to set options mainly useful for reporting servers.
# The server defaults are faster for transactions and fast SELECTs.
# Adjust sizes as needed, experiment to find the optimal values.
# join_buffer_size = 128M
# sort_buffer_size = 2M
# read_rnd_buffer_size = 2M
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
```
5. 修改ini配置文件中的安装目录和数据存放目录修改为mysql文件的路径
6. \#设置mysql的安装目录
basedir=D:\app\mysql-5.7.43-winx64
\#设置mysql数据库的数据的存放目录
datadir=D:\app\mysql-5.7.43-winx64\data
7. 打开cmd,初始化数据库
```powershell
mysqld --initialize
```
8. 初始化完成后,mysqld根目录下会自动新增data文件夹
![在这里插入图片描述](https://rustfs.wenyongdalucky.club:443/hexo/20210120153744844.png)
9. 打开data文件夹,找到.err后缀文本打开
![在这里插入图片描述](https://rustfs.wenyongdalucky.club:443/hexo/20210120153933128.png)
10. 找到文件password位置,红色框中为数据库初始化密码,后续修改初始化密码使用
```err
2023-10-07T04:37:02.330654Z 1 [Note] A temporary password is generated for root@localhost: (iw?Mw:Vs7n&
```
11. 安装数据库
```powershell
mysqld --install <服务名>
```
12. 启动服务
```powershell
net start mysql
```
13. 关闭服务
```powershell
net stop mysql
```
14. 修改初始密码
- 登录
```powershell
mysql -uroot -p'你的初始密码,步骤4中红框里的字符'
```
- 修改密码为 123456
```mysql
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'root';
```
15. 服务卸载
```powershell
net stop mysql
mysqld --remove
```
# Linux 安装MySQL
## 安装
1. 在浏览器下载Linux系统的MySQL客户端安装包。建议您下载的MySQL客户端版本高于已创建的GaussDB(for MySQL)实例中数据库版本。
在下载页面找到对应版本[链接](https://dev.mysql.com/downloads/file/?id=496982),以mysql-community-client-8.0.21-1.el6.x86_64为例,打开页面后,即可下载安装包。
![img](MySQL/zh-cn_image_0000001729034977.png)
2. 将安装包上传到ECS。
3. 执行以下命令安装MySQL客户端。
rpm -ivh mysql-community-client-8.0.21-1.el6.x86_64.rpm
> - 如果安装过程中报conflicts,可增加replacefiles参数重新安装,如下:
>
> rpm -ivh --replacefiles mysql-community-client-8.0.21-1.el6.x86_64.rpm
>
> - 如果安装过程中提示需要安装依赖包,可增加nodeps参数重新安装,如下:
>
> rpm -ivh --nodeps mysql-community-client-8.0.21-1.el6.x86_64.rpm
## 连接
1. **mysql -h** <*host*> **-P** *<port>* **-u** <*userName*> **-p**
示例:
mysql -h 192.168.0.16 -P 3306 -u root -p
参数说明
| 参数 | 说明 |
| ------------ | ---------------------------- |
| <*host*> | 获取的读写内网地址。 |
| *<port>* | 获取的数据库端口,默认3306。 |
| <*userName*> | 管理员帐号root。 |
2. 出现如下提示时,输入数据库帐号对应的密码。
```mysql
Enter password:
```
3. 报错mysql: error while loading shared libraries: libssl.so.10: cannot open shared object file: No such file or directory
下载rpm包:
https://mirrors.aliyun.com/centos/8/AppStream/x86_64/os/Packages/compat-openssl10-1.0.2o-3.el8.x86_64.rpm
安装rpm包:
```shell
rpm -i compat-openssl10-1.0.2o-3.el8.x86_64.rpm
错误:依赖检测失败:
make 被 compat-openssl10-1:1.0.2o-3.el8.x86_64 需要
rpm -i compat-openssl10-1.0.2o-3.el8.x86_64.rpm --nodeps --force
mysql: error while loading shared libraries: libncurses.so.5: cannot open shared object file: No such file or directory
cp /usr/lib64/libncurses.so.6 /usr/lib64/libncurses.so.5
mysql: error while loading shared libraries: libtinfo.so.5: cannot open shared object file: No such file or directory
cp /usr/lib64/libtinfo.so.6 /usr/lib64/libtinfo.so.5
```
# Linux 卸载MySQL
## 二进制方式
```shell
rpm -qa | grep -i mysql
# 如下所示
mysql-community-release-el7-5.noarch
mysql-community-libs-5.6.51-2.el7.x86_64
mysql-community-client-5.6.51-2.el7.x86_64
mysql-community-server-5.6.51-2.el7.x86_64
mysql-community-common-5.6.51-2.el7.x86_64
systemctl stop mysqld
rpm -ev mysql-community-release-el7-5.noarch
rpm -ev mysql-community-libs-5.6.51-2.el7.x86_64
rpm -ev mysql-community-client-5.6.51-2.el7.x86_64
rpm -ev mysql-community-server-5.6.51-2.el7.x86_64
rpm -ev mysql-community-common-5.6.51-2.el7.x86_64
find / -name mysql
# 如下所示
/var/lib/mysql
/var/lib/mysql/mysql
/usr/local/mysql
/usr/lib64/mysql
/usr/share/mysql
/usr/bin/mysql
/etc/logrotate.d/mysql
/etc/selinux/targeted/active/modules/100/mysql
rm -rf /var/lib/mysql
rm -rf /var/lib/mysql/mysql
rm -rf /usr/local/mysql
rm -rf /usr/lib64/mysql
rm -rf /usr/share/mysql
rm -rf /usr/bin/mysql
rm -rf /etc/logrotate.d/mysql
rm -rf /etc/selinux/targeted/active/modules/100/mysql
rm -rf /etc/my.cnf
rpm -qa | grep -i mysql
```
# mysqldump备份数据库
@@ -248,226 +477,6 @@ setenforce 0
永久关闭SELinux
# Windows 下安装 绿色版
先下载[MySQL :: Download MySQL Community Server](https://dev.mysql.com/downloads/mysql/)
![image-20231007124717167](https://markdownhexo.oss-cn-hangzhou.aliyuncs.com/img/image-20231007124717167.png)
1. 解压下载好的压缩包
![在这里插入图片描述](https://rustfs.wenyongdalucky.club:443/hexo/20210120105901505.png)
2. 解压后得到
![在这里插入图片描述](https://rustfs.wenyongdalucky.club:443/hexo/20210120105247435.png)
3. 新建一个 `my.ini`文件
![在这里插入图片描述](https://rustfs.wenyongdalucky.club:443/hexo/20210120110525427.png)
4. 解压后的mysql根目录下没有my.ini文件,自己去网上找一份就可或者使用我在后面给出的代码。.ini文件会在初始化mysql中用到
```ini
# For advice on how to change settings please see
# http=//dev.mysql.com/doc/refman/5.7/en/server-configuration-defaults.html
# *** DO NOT EDIT THIS FILE. It's a template which will be copied to the
# *** default location during install, and will be replaced if you
# *** upgrade to a newer version of MySQL.
[client]
port = 3306
default-character-set = utf8
[mysqld]
# Remove leading # and set to the amount of RAM for the most important data
# cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%.
# innodb_buffer_pool_size = 128M
# Remove leading # to turn on a very important data integrity option= logging
# changes to the binary log between backups.
# log_bin
port = 3306
# These are commonly set, remove the # and set as required.
basedir="D:\app\mysql-5.7.43-winx64"
datadir="D:\app\mysql-5.7.43-winx64\data"
# server_id = .....
character_set_server = utf8
# Remove leading # to set options mainly useful for reporting servers.
# The server defaults are faster for transactions and fast SELECTs.
# Adjust sizes as needed, experiment to find the optimal values.
# join_buffer_size = 128M
# sort_buffer_size = 2M
# read_rnd_buffer_size = 2M
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
```
5. 修改ini配置文件中的安装目录和数据存放目录修改为mysql文件的路径
6. \#设置mysql的安装目录
basedir=D:\app\mysql-5.7.43-winx64
\#设置mysql数据库的数据的存放目录
datadir=D:\app\mysql-5.7.43-winx64\data
7. 打开cmd,初始化数据库
```powershell
mysqld --initialize
```
8. 初始化完成后,mysqld根目录下会自动新增data文件夹
![在这里插入图片描述](https://rustfs.wenyongdalucky.club:443/hexo/20210120153744844.png)
9. 打开data文件夹,找到.err后缀文本打开
![在这里插入图片描述](https://rustfs.wenyongdalucky.club:443/hexo/20210120153933128.png)
10. 找到文件password位置,红色框中为数据库初始化密码,后续修改初始化密码使用
```err
2023-10-07T04:37:02.330654Z 1 [Note] A temporary password is generated for root@localhost: (iw?Mw:Vs7n&
```
11. 安装数据库
```powershell
mysqld --install <服务名>
```
12. 启动服务
```powershell
net start mysql
```
13. 关闭服务
```powershell
net stop mysql
```
14. 修改初始密码
- 登录
```powershell
mysql -uroot -p'你的初始密码,步骤4中红框里的字符'
```
- 修改密码为 123456
```mysql
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'root';
```
15. 服务卸载
```powershell
net stop mysql
mysqld --remove
```
# Linux 安装MySQL
## 安装
1. 在浏览器下载Linux系统的MySQL客户端安装包。建议您下载的MySQL客户端版本高于已创建的GaussDB(for MySQL)实例中数据库版本。
在下载页面找到对应版本[链接](https://dev.mysql.com/downloads/file/?id=496982),以mysql-community-client-8.0.21-1.el6.x86_64为例,打开页面后,即可下载安装包。
![img](MySQL/zh-cn_image_0000001729034977.png)
2. 将安装包上传到ECS。
3. 执行以下命令安装MySQL客户端。
rpm -ivh mysql-community-client-8.0.21-1.el6.x86_64.rpm
> - 如果安装过程中报conflicts,可增加replacefiles参数重新安装,如下:
>
> rpm -ivh --replacefiles mysql-community-client-8.0.21-1.el6.x86_64.rpm
>
> - 如果安装过程中提示需要安装依赖包,可增加nodeps参数重新安装,如下:
>
> rpm -ivh --nodeps mysql-community-client-8.0.21-1.el6.x86_64.rpm
## 连接
1. **mysql -h** <*host*> **-P** *<port>* **-u** <*userName*> **-p**
示例:
mysql -h 192.168.0.16 -P 3306 -u root -p
参数说明
| 参数 | 说明 |
| ------------ | ---------------------------- |
| <*host*> | 获取的读写内网地址。 |
| *<port>* | 获取的数据库端口,默认3306。 |
| <*userName*> | 管理员帐号root。 |
2. 出现如下提示时,输入数据库帐号对应的密码。
```mysql
Enter password:
```
3. 报错mysql: error while loading shared libraries: libssl.so.10: cannot open shared object file: No such file or directory
下载rpm包:
https://mirrors.aliyun.com/centos/8/AppStream/x86_64/os/Packages/compat-openssl10-1.0.2o-3.el8.x86_64.rpm
安装rpm包:
```shell
rpm -i compat-openssl10-1.0.2o-3.el8.x86_64.rpm
错误:依赖检测失败:
make 被 compat-openssl10-1:1.0.2o-3.el8.x86_64 需要
rpm -i compat-openssl10-1.0.2o-3.el8.x86_64.rpm --nodeps --force
mysql: error while loading shared libraries: libncurses.so.5: cannot open shared object file: No such file or directory
cp /usr/lib64/libncurses.so.6 /usr/lib64/libncurses.so.5
mysql: error while loading shared libraries: libtinfo.so.5: cannot open shared object file: No such file or directory
cp /usr/lib64/libtinfo.so.6 /usr/lib64/libtinfo.so.5
```
# Linux 卸载MySQL
## 二进制方式
```shell
rpm -qa | grep -i mysql
# 如下所示
mysql-community-release-el7-5.noarch
mysql-community-libs-5.6.51-2.el7.x86_64
mysql-community-client-5.6.51-2.el7.x86_64
mysql-community-server-5.6.51-2.el7.x86_64
mysql-community-common-5.6.51-2.el7.x86_64
systemctl stop mysqld
rpm -ev mysql-community-release-el7-5.noarch
rpm -ev mysql-community-libs-5.6.51-2.el7.x86_64
rpm -ev mysql-community-client-5.6.51-2.el7.x86_64
rpm -ev mysql-community-server-5.6.51-2.el7.x86_64
rpm -ev mysql-community-common-5.6.51-2.el7.x86_64
find / -name mysql
# 如下所示
/var/lib/mysql
/var/lib/mysql/mysql
/usr/local/mysql
/usr/lib64/mysql
/usr/share/mysql
/usr/bin/mysql
/etc/logrotate.d/mysql
/etc/selinux/targeted/active/modules/100/mysql
rm -rf /var/lib/mysql
rm -rf /var/lib/mysql/mysql
rm -rf /usr/local/mysql
rm -rf /usr/lib64/mysql
rm -rf /usr/share/mysql
rm -rf /usr/bin/mysql
rm -rf /etc/logrotate.d/mysql
rm -rf /etc/selinux/targeted/active/modules/100/mysql
rm -rf /etc/my.cnf
rpm -qa | grep -i mysql
```
# MySQL 客户端