当前位置:   article > 正文

Linux上的MySQL四种安装部署方式_linux 部署mysql

linux 部署mysql

1、仓库安装

  1. #查看本机版本
  2. [root@localhost ~]# cat /etc/redhat-release
  3. Red Hat Enterprise Linux release 9.1 (Plow)
  4. #在mysql官网上找到本机需要版本的域名然后用rpm安装下载下来
  5. [root@localhost ~]# rpm -ivh http://repo.mysql.com//mysql80-community-release-el9-1.noarch.rpm
  6. 获取http://repo.mysql.com//mysql80-community-release-el9-1.noarch.rpm
  7. 警告:/var/tmp/rpm-tmp.v8CBoF: 头V4 RSA/SHA256 Signature, 密钥 ID 3a79bd29: NOKEY
  8. Verifying... ################################# [100%]
  9. 准备中... ################################# [100%]
  10. 正在升级/安装...
  11. 1:mysql80-community-release-el9-1 ################################# [100%]
  12. #之前用的https://报以下错误,查看一下是网址的问题,改用http://域名
  13. 获取https://repo.mysql.com//mysql80-community-release-el9-1.noarch.rpm
  14. curl: (28) Operation timed out after 300710 milliseconds with 0 out of 0 bytes received
  15. 错误:跳过 https://repo.mysql.com//mysql80-community-release-el9-1.noarch.rpm - 传输失败
  16. #安装mysql服务器
  17. [root@localhost ~]# dnf install mysql-server -y
  18. 正在更新 Subscription Management 软件仓库。
  19. 无法读取客户身份
  20. 本系统尚未在权利服务器中注册。可使用 subscription-manager 进行注册。
  21. 依赖关系解决。
  22. ========================================================================================================================
  23. 软件包 架构 版本 仓库 大小
  24. ========================================================================================================================
  25. 安装:
  26. mysql-community-server x86_64 8.0.32-1.el9 mysql80-community 49 M
  27. 安装依赖关系:
  28. mysql-community-client x86_64 8.0.32-1.el9 mysql80-community 3.9 M
  29. mysql-community-client-plugins x86_64 8.0.32-1.el9 mysql80-community 1.4 M
  30. mysql-community-common x86_64 8.0.32-1.el9 mysql80-community 544 k
  31. mysql-community-icu-data-files x86_64 8.0.32-1.el9 mysql80-community 2.2 M
  32. mysql-community-libs x86_64 8.0.32-1.el9 mysql80-community 1.5 M
  33. 事务概要
  34. ========================================================================================================================
  35. 安装 6 软件包
  36. 总下载:59 M
  37. 安装大小:335 M
  38. 下载软件包:
  39. (1/6): mysql-community-common-8.0.32-1.el9.x86_64.rpm 368 kB/s | 544 kB 00:01
  40. (2/6): mysql-community-client-plugins-8.0.32-1.el9.x86_64.rpm 844 kB/s | 1.4 MB 00:01
  41. (3/6): mysql-community-client-8.0.32-1.el9.x86_64.rpm 1.9 MB/s | 3.9 MB 00:02
  42. (4/6): mysql-community-icu-data-files-8.0.32-1.el9.x86_64.rpm 2.9 MB/s | 2.2 MB 00:00
  43. (5/6): mysql-community-libs-8.0.32-1.el9.x86_64.rpm 1.6 MB/s | 1.5 MB 00:00
  44. (6/6): mysql-community-server-8.0.32-1.el9.x86_64.rpm 7.4 MB/s | 49 MB 00:06
  45. ------------------------------------------------------------------------------------------------------------------------
  46. 总计 6.7 MB/s | 59 MB 00:08
  47. 运行事务检查
  48. 事务检查成功。
  49. 运行事务测试
  50. 事务测试成功。
  51. 运行事务
  52. 准备中 : 1/1
  53. 安装 : mysql-community-common-8.0.32-1.el9.x86_64 1/6
  54. 安装 : mysql-community-client-plugins-8.0.32-1.el9.x86_64 2/6
  55. 安装 : mysql-community-libs-8.0.32-1.el9.x86_64 3/6
  56. 运行脚本: mysql-community-libs-8.0.32-1.el9.x86_64 3/6
  57. 安装 : mysql-community-client-8.0.32-1.el9.x86_64 4/6
  58. 安装 : mysql-community-icu-data-files-8.0.32-1.el9.x86_64 5/6
  59. 运行脚本: mysql-community-server-8.0.32-1.el9.x86_64 6/6
  60. 安装 : mysql-community-server-8.0.32-1.el9.x86_64 6/6
  61. 运行脚本: mysql-community-server-8.0.32-1.el9.x86_64 6/6
  62. 验证 : mysql-community-client-8.0.32-1.el9.x86_64 1/6
  63. 验证 : mysql-community-client-plugins-8.0.32-1.el9.x86_64 2/6
  64. 验证 : mysql-community-common-8.0.32-1.el9.x86_64 3/6
  65. 验证 : mysql-community-icu-data-files-8.0.32-1.el9.x86_64 4/6
  66. 验证 : mysql-community-libs-8.0.32-1.el9.x86_64 5/6
  67. 验证 : mysql-community-server-8.0.32-1.el9.x86_64 6/6
  68. 已更新安装的产品。
  69. 已安装:
  70. mysql-community-client-8.0.32-1.el9.x86_64 mysql-community-client-plugins-8.0.32-1.el9.x86_64
  71. mysql-community-common-8.0.32-1.el9.x86_64 mysql-community-icu-data-files-8.0.32-1.el9.x86_64
  72. mysql-community-libs-8.0.32-1.el9.x86_64 mysql-community-server-8.0.32-1.el9.x86_64
  73. 完毕!
  74. #查看所装的包
  75. [root@localhost ~]# rpm -qa | grep mysql
  76. mysql80-community-release-el9-1.noarch
  77. mysql-community-common-8.0.32-1.el9.x86_64
  78. mysql-community-client-plugins-8.0.32-1.el9.x86_64
  79. mysql-community-libs-8.0.32-1.el9.x86_64
  80. mysql-community-client-8.0.32-1.el9.x86_64
  81. mysql-community-icu-data-files-8.0.32-1.el9.x86_64
  82. mysql-community-server-8.0.32-1.el9.x86_64
  83. #启动mysql
  84. [root@localhost ~]# systemctl start mysqld
  85. [root@localhost ~]# systemctl status mysqld
  86. ● mysqld.service - MySQL Server
  87. Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; vendor pre>
  88. Active: active (running) since Sun 2023-02-12 18:14:13 CST; 30min ago
  89. Docs: man:mysqld(8)
  90. http://dev.mysql.com/doc/refman/en/using-systemd.html
  91. Process: 1053 ExecStartPre=/usr/bin/mysqld_pre_systemd (code=exited, status=>
  92. Main PID: 1545 (mysqld)
  93. Status: "Server is operational"
  94. Tasks: 39 (limit: 10756)
  95. Memory: 248.9M
  96. CPU: 11.780s
  97. CGroup: /system.slice/mysqld.service
  98. └─1545 /usr/sbin/mysqld
  99. 212 18:14:05 localhost systemd[1]: Starting MySQL Server...
  100. 212 18:14:13 localhost.localdomain systemd[1]: Started MySQL Server.
  101. #查看数据库密码,在/var/log/mysqld.log,用grep筛选出来
  102. [root@localhost ~]# grep password /var/log/mysqld.log
  103. 2023-02-10T01:19:30.736981Z 6 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: Z+wHe6B4rfr)
  104. #登录数据库
  105. [root@localhost ~]# mysql -uroot -pZ+wHe6B4rfr
  106. #登录之后必须先修改用户密码,默认密码策略要求密码至少包含一个大写字母、一个小写字母、一位数字和一个特殊字符,并且密码总长度至少为8个字符。
  107. mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'Admin123!';
  108. Query OK, 0 rows affected (0.00 sec)
  109. mysql> show databases;
  110. +--------------------+
  111. | Database |
  112. +--------------------+
  113. | information_schema |
  114. | mysql |
  115. | performance_schema |
  116. | sys |
  117. +--------------------+
  118. 4 rows in set (0.00 sec)
  119. 仓库安装完毕,可以尽情的在mysql中玩耍啦
  120. #想卸载数据库也不是不可以,输入以下指令就可以啦
  121. [root@localhost ~]# dnf remove mysql-server -y
  122. [root@localhost ~]# rpm -qa | grep mysql
  123. [root@localhost ~]# dnf remove mysql80-community-release -y
  124. [root@localhost ~]# rm -rf /var/lib/mysql/ /var/log/mysqld.log
  125. #你可以尝试其他方式的安装咯

2、本地安装

  1. #为了保证本地安装的成功,先新建一个目录
  2. [root@localhost ~]# mkdir mysql
  3. #进入mysql目录中,把需要的mysql包搞下来
  4. [root@localhost ~]# cd mysql/
  5. [root@localhost mysql]# wget https://cdn.mysql.com//Downloads/MySQL-8.0/mysql-8.0.32-1.el9.x86_64.rpm-bundle.tar
  6. --2023-02-12 18:59:42-- https://cdn.mysql.com//Downloads/MySQL-8.0/mysql-8.0.32-1.el9.x86_64.rpm-bundle.tar
  7. 正在解析主机 cdn.mysql.com (cdn.mysql.com)... 223.119.242.56
  8. 正在连接 cdn.mysql.com (cdn.mysql.com)|223.119.242.56|:443... 已连接。
  9. 已发出 HTTP 请求,正在等待回应... 200 OK
  10. 长度:849367040 (810M) [application/x-tar]
  11. 正在保存至: “mysql-8.0.32-1.el9.x86_64.rpm-bundle.tar”
  12. mysql-8.0.32-1.el9.x86_64.rpm 100%[=================================================>] 810.02M 11.2MB/s 用时 75s
  13. 2023-02-12 19:01:22 (10.8 MB/s) - 已保存 “mysql-8.0.32-1.el9.x86_64.rpm-bundle.tar” [849367040/849367040])
  14. #解压刚才搞下来的包
  15. [root@localhost mysql]# tar xvf mysql-8.0.32-1.el9.x86_64.rpm-bundle.tar
  16. mysql-community-client-8.0.32-1.el9.x86_64.rpm
  17. mysql-community-client-debuginfo-8.0.32-1.el9.x86_64.rpm
  18. mysql-community-client-plugins-8.0.32-1.el9.x86_64.rpm
  19. mysql-community-client-plugins-debuginfo-8.0.32-1.el9.x86_64.rpm
  20. mysql-community-common-8.0.32-1.el9.x86_64.rpm
  21. mysql-community-debuginfo-8.0.32-1.el9.x86_64.rpm
  22. mysql-community-debugsource-8.0.32-1.el9.x86_64.rpm
  23. 实际下面很多,俺只截取了一点
  24. #安装mysql-community-server所产生的依赖包
  25. [root@localhost mysql]# rpm -ivh mysql-community-server-8.0.32-1.el9.x86_64.rpm mysql-community-client-8.0.32-1.el9.x86_64.rpm mysql-community-common-8.0.32-1.el9.x86_64.rpm mysql-community-icu-data-files-8.0.32-1.el9.x86_64.rpm mysql-community-client-plugins-8.0.32-1.el9.x86_64.rpm mysql-community-libs-8.0.32-1.el9.x86_64.rpm
  26. Verifying... ################################# [100%]
  27. 准备中... ################################# [100%]
  28. 正在升级/安装...
  29. 1:mysql-community-client-plugins-8.################################# [ 17%]
  30. 2:mysql-community-common-8.0.32-1.e################################# [ 33%]
  31. 3:mysql-community-libs-8.0.32-1.el9################################# [ 50%]
  32. 4:mysql-community-client-8.0.32-1.e################################# [ 67%]
  33. 5:mysql-community-icu-data-files-8.################################# [ 83%]
  34. 6:mysql-community-server-8.0.32-1.e################################# [100%]
  35. #启动mysql服务
  36. [root@localhost mysql]# systemctl start mysqld
  37. [root@localhost mysql]# systemctl status mysqld
  38. ● mysqld.service - MySQL Server
  39. Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; vendor pre>
  40. Active: active (running) since Sun 2023-02-12 18:14:13 CST; 50min ago
  41. Docs: man:mysqld(8)
  42. http://dev.mysql.com/doc/refman/en/using-systemd.html
  43. Process: 1053 ExecStartPre=/usr/bin/mysqld_pre_systemd (code=exited, status=>
  44. Main PID: 1545 (mysqld)
  45. Status: "Server is operational"
  46. Tasks: 39 (limit: 10756)
  47. Memory: 212.2M
  48. CPU: 17.560s
  49. CGroup: /system.slice/mysqld.service
  50. └─1545 /usr/sbin/mysqld
  51. 212 18:14:05 localhost systemd[1]: Starting MySQL Server...
  52. 212 18:14:13 localhost.localdomain systemd[1]: Started MySQL Server.
  53. #查看数据库密码,在/var/log/mysqld.log,用grep筛选出来
  54. [root@localhost ~]# grep password /var/log/mysqld.log
  55. 2023-02-10T01:19:30.736981Z 6 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: Z+wHe6B4rfr)
  56. #登录数据库
  57. [root@localhost ~]# mysql -uroot -pZ+wHe6B4rfr
  58. #登录之后必须先修改用户密码,默认密码策略要求密码至少包含一个大写字母、一个小写字母、一位数字和一个特殊字符,并且密码总长度至少为8个字符。
  59. mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'Admin123!';
  60. Query OK, 0 rows affected (0.00 sec)
  61. mysql> show databases;
  62. +--------------------+
  63. | Database |
  64. +--------------------+
  65. | information_schema |
  66. | mysql |
  67. | performance_schema |
  68. | sys |
  69. +--------------------+
  70. 4 rows in set (0.00 sec)
  71. 本地安装就好啦,当然卸载也很简单
  72. [root@localhost mysql]# rpm -qa | grep mysql
  73. mysql-community-common-8.0.32-1.el9.x86_64
  74. mysql-community-client-plugins-8.0.32-1.el9.x86_64
  75. mysql-community-libs-8.0.32-1.el9.x86_64
  76. mysql-community-client-8.0.32-1.el9.x86_64
  77. mysql-community-icu-data-files-8.0.32-1.el9.x86_64
  78. mysql-community-server-8.0.32-1.el9.x86_64
  79. [root@localhost mysql]# rpm -evh mysql-community-common mysql-community-client-pplugins mysql-community-libs mysql-community-client mysql-community-icu-data-files mysql-community-server
  80. [root@localhost ~]# rm -rf /var/lib/mysql/ /var/log/mysqld.log
  81. 这就可以咯,让我们继续下一种安装方式

3、容器安装

  1. #容器安装的一些依赖包
  2. [root@localhost ~]# dnf install -y yum-utils device-mapper-persistent-data lvm2
  3. 正在更新 Subscription Management 软件仓库。
  4. 无法读取客户身份
  5. 本系统尚未在权利服务器中注册。可使用 subscription-manager 进行注册。
  6. 上次元数据过期检查:1:47:42 前,执行于 Sat 11 Feb 2023 15:08:09 CST。
  7. 软件包 device-mapper-persistent-data-0.9.0-13.el9.x86_64 已安装。
  8. 软件包 lvm2-9:2.03.16-3.el9.x86_64 已安装。
  9. 依赖关系解决。
  10. ========================================================================================================================
  11. 软件包 架构 版本 仓库 大小
  12. ========================================================================================================================
  13. 安装:
  14. yum-utils noarch 4.1.0-3.el9 base 45 k
  15. 事务概要
  16. ========================================================================================================================
  17. 安装 1 软件包
  18. 总计:45 k
  19. 安装大小:23 k
  20. 下载软件包:
  21. 运行事务检查
  22. 事务检查成功。
  23. 运行事务测试
  24. 事务测试成功。
  25. 运行事务
  26. 准备中 : 1/1
  27. 安装 : yum-utils-4.1.0-3.el9.noarch 1/1
  28. 运行脚本: yum-utils-4.1.0-3.el9.noarch 1/1
  29. 验证 : yum-utils-4.1.0-3.el9.noarch 1/1
  30. 已更新安装的产品。
  31. 已安装:
  32. yum-utils-4.1.0-3.el9.noarch
  33. 完毕!
  34. #容器仓库添加阿里云的
  35. [root@localhost ~]# yum-config-manager --add-repo https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
  36. 正在更新 Subscription Management 软件仓库。
  37. 无法读取客户身份
  38. 本系统尚未在权利服务器中注册。可使用 subscription-manager 进行注册。
  39. 添加仓库自:https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
  40. #下载docker时修改网站为阿里云网站
  41. [root@localhost ~]# sed -i 's+download.docker.com+mirrors.aliyun.com/docker-ce+' /etc/yum.repos.d/docker-ce.repo
  42. #安装docker-ce
  43. [root@localhost ~]# dnf install docker-ce --allowerasing -y
  44. #启动容器
  45. [root@localhost ~]# systemctl start docker
  46. [root@localhost ~]# systemctl status docker
  47. ● docker.service - Docker Application Container Engine
  48. Loaded: loaded (/usr/lib/systemd/system/docker.service; disabled; vendor preset: disabled)
  49. Active: active (running) since Sat 2023-02-12 19:21:32 CST; 7s ago
  50. TriggeredBy: ● docker.socket
  51. Docs: https://docs.docker.com
  52. Main PID: 9559 (dockerd)
  53. Tasks: 7
  54. Memory: 24.5M
  55. CPU: 173ms
  56. CGroup: /system.slice/docker.service
  57. └─9559 /usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock
  58. Feb 11 17:12:31 192.168.130.128 dockerd[9559]: time="2023-02-12T17:12:31.723160244+08:00" level=info msg="[core] [Chann>
  59. Feb 11 17:12:31 192.168.130.128 dockerd[9559]: time="2023-02-12T17:12:31.763898158+08:00" level=info msg="Loading conta>
  60. Feb 11 17:12:32 192.168.130.128 dockerd[9559]: time="2023-02-12T17:12:32.443463649+08:00" level=info msg="Default bridg>
  61. Feb 11 17:12:32 192.168.130.128 dockerd[9559]: time="2023-02-12T17:12:32.626962098+08:00" level=info msg="Firewalld: in>
  62. Feb 11 17:12:32 192.168.130.128 dockerd[9559]: time="2023-02-12T17:12:32.854013030+08:00" level=info msg="Loading conta>
  63. Feb 11 17:12:32 192.168.130.128 dockerd[9559]: time="2023-02-12T17:12:32.887442173+08:00" level=info msg="Docker daemon>
  64. Feb 11 17:12:32 192.168.130.128 dockerd[9559]: time="2023-02-12T17:12:32.888149989+08:00" level=info msg="Daemon has co>
  65. Feb 11 17:12:32 192.168.130.128 dockerd[9559]: time="2023-02-12T17:12:32.918032658+08:00" level=info msg="[core] [Serve>
  66. Feb 11 17:12:32 192.168.130.128 systemd[1]: Started Docker Application Container Engine.
  67. Feb 11 17:12:32 192.168.130.128 dockerd[9559]: time="2023-02-11T17:12:32.935974546+08:00" level=info msg="API listen on
  68. #测试容器
  69. [root@localhost ~]# docker version
  70. Client: Docker Engine - Community
  71. Version: 23.0.1
  72. API version: 1.42
  73. Go version: go1.19.5
  74. Git commit: a5ee5b1
  75. [root@localhost ~]# docker run hello-world
  76. Unable to find image 'hello-world:latest' locally
  77. latest: Pulling from library/hello-world
  78. 2db29710123e: Pull complete
  79. Digest: sha256:aa0cc8055b82dc2509bed2e19b275c8f463506616377219d9642221ab53cf9fe
  80. Status: Downloaded newer image for hello-world:latest
  81. #运行mysqltest容器
  82. [root@localhost ~]# docker run --name mysqltest -e MYSQL_ROOT_PASSWORD=123456 -d mysql
  83. Unable to find image 'mysql:latest' locally
  84. latest: Pulling from library/mysql
  85. 197c1adcd755: Pull complete
  86. 45f2e353f7d2: Pull complete
  87. #先进容器再进入数据库
  88. [root@192 ~]# docker exec -it mysqltest /bin/bash
  89. bash-4.4# mysql -uroot -p
  90. Enter password:
  91. Welcome to the MySQL monitor. Commands end with ; or \g.
  92. Your MySQL connection id is 8
  93. Server version: 8.0.32 MySQL Community Server - GPL
  94. Copyright (c) 2000, 2023, Oracle and/or its affiliates.
  95. Oracle is a registered trademark of Oracle Corporation and/or its
  96. affiliates. Other names may be trademarks of their respective
  97. owners.
  98. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
  99. mysql> show databases;
  100. +--------------------+
  101. | Database |
  102. +--------------------+
  103. | information_schema |
  104. | mysql |
  105. | performance_schema |
  106. | sys |
  107. +--------------------+
  108. 4 rows in set (0.00 sec)
  109. 容器安装就阔以咯

4、源码安装

源码安装前需关机把虚拟机的运行内存设置到4G以上

  1. #添加用户和组
  2. [root@localhost ~]# groupadd mysql
  3. [root@localhost ~]# useradd -r -g mysql -s /bin/false mysql
  4. #下载源码安装包
  5. [root@localhost ~]# wget https://cdn.mysql.com//Downloads/MySQL-8.0/mysql-boost-8.0.32.tar.gz
  6. --2023-02-12 19:36:31-- https://cdn.mysql.com//Downloads/MySQL-8.0/mysql-boost-8.0.32.tar.gz
  7. 正在解析主机 cdn.mysql.com (cdn.mysql.com)... 2.19.84.217
  8. 正在连接 cdn.mysql.com (cdn.mysql.com)|2.19.84.217|:443... 已连接。
  9. 已发出 HTTP 请求,正在等待回应... 200 OK
  10. 长度:436207624 (416M) [application/x-tar-gz]
  11. 正在保存至: “mysql-boost-8.0.32.tar.gz.1
  12. mysql-boost-8.0.32.tar.gz.1 100%[=================================================>] 416.00M 7.60MB/s 用时 62s
  13. 2023-02-12 19:37:11 (6.76 MB/s) - 已保存 “mysql-boost-8.0.32.tar.gz.1” [436207624/436207624])
  14. #解压源码安装包
  15. [root@localhost ~]# tar xvf mysql-boost-8.0.32.tar.gz
  16. mysql-8.0.32/
  17. mysql-8.0.32/.clang-format
  18. mysql-8.0.32/.gitconfig
  19. mysql-8.0.32/CMakeLists.txt
  20. mysql-8.0.32/Docs/
  21. #安装编译器需要的工具
  22. [root@localhost ~]# yum install gcc gcc-c++ cmake -y
  23. 正在更新 Subscription Management 软件仓库。
  24. 无法读取客户身份
  25. 本系统尚未在权利服务器中注册。可使用 subscription-manager 进行注册。
  26. 上次元数据过期检查:0:45:37 前,执行于 Sat 12 Feb 2023 19:12:40 CST。
  27. 依赖关系解决。
  28. ========================================================================================================================
  29. 软件包 架构 版本 仓库 大小
  30. ========================================================================================================================
  31. 安装:
  32. cmake x86_64 3.20.2-7.el9 app 6.7 M
  33. gcc x86_64 11.3.1-2.1.el9 app 32 M
  34. gcc-c++ x86_64 11.3.1-2.1.el9
  35. #安装编译时需要的库
  36. [root@localhost ~]# yum install cmake gcc-toolset-12-gcc gcc-toolset-12-gcc-c++ gcc-toolset-12-binutils openssl-devel ncurses-devel libtirpc rpcgen git -y
  37. [root@localhost ~]# rpm -ivh https://mirrors.tuna.tsinghua.edu.cn/centos-stream/9-stream/CRB/x86_64/os/Packages/libtirpc-devel-1.3.3-0.el9.x86_64.rpm
  38. 获取https://mirrors.tuna.tsinghua.edu.cn/centos-stream/9-stream/CRB/x86_64/os/Packages/libtirpc-devel-1.3.3-0.el9.x86_64.rpm
  39. 警告:/var/tmp/rpm-tmp.5Pu21j: 头V3 RSA/SHA256 Signature, 密钥 ID 8483c65d: NOKEY
  40. Verifying... ################################# [100%]
  41. 准备中... ################################# [100%]
  42. 正在升级/安装...
  43. 1:libtirpc-devel-1.3.3-0.el9 ################################# [100%]
  44. #进入mysql-8.0.32/目录,创建bld目录,然后起服务
  45. [root@localhost ~]# cd mysql-8.0.32/
  46. [root@localhost mysql-8.0.32]# mkdir bld
  47. [root@localhost mysql-8.0.32]# cd bld
  48. [root@localhost bld]# cmake .. -DWITH_BOOST=../boost/boost_1_77_0/
  49. -- Running cmake version 3.20.2
  50. -- Found Git: /usr/bin/git (found version "2.31.1")
  51. -- This is .el9. as found from 'rpm -qf /'
  52. #编译(此过程大概需要2-3小时,根据电脑性能不同,时间不同,慢慢等咯)
  53. [root@localhost bld]# make
  54. [ 0%] Built target abi_check
  55. [ 0%] Building C object extra/zlib/zlib-1.2.13/CMakeFiles/zlib_objlib.dir/adler32.c.o
  56. [ 0%] Building C object extra/zlib/zlib-1.2.13/CMakeFiles/zlib_objlib.dir/compress.c.o
  57. [ 0%] Building C object extra/zlib/zlib-1.2.13/CMakeFiles/zlib_objlib.dir/crc32.c.o
  58. [root@localhost bld]# make install
  59. [ 0%] Built target abi_check
  60. Consolidate compiler generated dependencies of target zlib_objlib
  61. [ 1%] Built target zlib_objlib
  62. # 创建目录并修改所属者和所属组并修改权限
  63. [root@localhost bld]# cd /usr/local/mysql
  64. [root@localhost mysql]# mkdir mysql-files
  65. [root@localhost mysql]# chown mysql:mysql mysql-files
  66. [root@localhost mysql]# chmod 750 mysql-files
  67. #初始化数据库
  68. [root@localhost mysql]# ./bin/mysqld --initialize --user=mysql
  69. 2023-02-12T19:54:21.356408Z 0 [System] [MY-013169] [Server] /usr/local/mysql/bin/mysqld (mysqld 8.0.32) initializing of server in progress as process 46939
  70. 2023-02-12T19:54:21.378025Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started.
  71. 2023-02-12T19:54:22.324104Z 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended.
  72. 2023-02-12T19:54:23.609467Z 6 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: >k-Pqm=L6oXt
  73. #开启支持ssl加密
  74. [root@localhost mysql]# ./bin/mysql_ssl_rsa_setup
  75. #后台启动mysql进程
  76. [root@localhost mysql]# ./bin/mysqld_safe --user=mysql &
  77. #进入数据库(临时密码在初始化时屏幕上有输出)
  78. [root@192 mysql]# ./bin/mysql -uroot -p'Z+wHe6B4rfr'
  79. #登录之后必须先修改用户密码,默认密码策略要求密码至少包含一个大写字母、一个小写字母、一位数字和一个特殊字符,并且密码总长度至少为8个字符。
  80. mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'Admin123!';
  81. Query OK, 0 rows affected (0.00 sec)
  82. mysql> show databases;
  83. +--------------------+
  84. | Database |
  85. +--------------------+
  86. | information_schema |
  87. | mysql |
  88. | performance_schema |
  89. | sys |
  90. +--------------------+
  91. 4 rows in set (0.00 sec)
  92. 以上就是源码安装,学废了吗

停下休息的时候,不要忘记别人在奔跑。

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/菜鸟追梦旅行/article/detail/522816
推荐阅读
相关标签
  

闽ICP备14008679号