当前位置:   article > 正文

【MySQL】MySQL 8.4.0 长期支持版(LTS)安装

mysql 8.4

        就在2024年 “5.1” 节前,MySQL官方发布了8.4.0长期支持版(LTS - Long Term Support)。根据官方提供的文档,在本地虚拟机进行安装测试。

        安装、配置和启动过程记录如下:

        第一步,上传到安装包(mysql-commercial-8.4.0-linux-glibc2.17-x86_64.tar.xz)到虚拟机,并解压。

  1. [root@vm-3rd89n7dd ~]# rz
  2. rz waiting to receive.
  3. Starting zmodem transfer. Press Ctrl+C to cancel.
  4. Transferring mysql-commercial-8.4.0-linux-glibc2.17-x86_64.tar.xz...
  5. 100% 518611 KB 27295 KB/sec 00:00:19 0 Errors
  6. [root@vm-3rd89n7dd ~]# tar -xf mysql-commercial-8.4.0-linux-glibc2.17-x86_64.tar.xz
  7. [root@vm-3rd89n7dd ~]# mv mysql-commercial-8.4.0-linux-glibc2.17-x86_64 /usr/local/mysql

        第二步,创建mysql用户和组,并给相关目录授权。

  1. [root@vm-3rd89n7dd ~]# groupadd mysql
  2. [root@vm-3rd89n7dd ~]# useradd -r -g mysql -s /bin/false mysql
  3. [root@vm-3rd89n7dd ~]# cd /usr/local/mysql
  4. [root@vm-3rd89n7dd mysql]# mkdir mysql-files
  5. [root@vm-3rd89n7dd mysql]# chown mysql:mysql mysql-files
  6. [root@vm-3rd89n7dd mysql]# chmod 750 mysql-files

        第三步,用户密码初始化(注意下面信息打印出来 temporary password ,登录数据库操作时,会提示必须修改

  1. [root@vm-3rd89n7dd mysql]# bin/mysqld --initialize --user=mysql
  2. 2024-05-07T06:22:58.045209Z 0 [System] [MY-015017] [Server] MySQL Server Initialization - start.
  3. 2024-05-07T06:22:58.047263Z 0 [System] [MY-013169] [Server] /usr/local/mysql/bin/mysqld (mysqld 8.4.0-commercial) initializing of server in progress as process 3904
  4. 2024-05-07T06:22:58.064126Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started.
  5. 2024-05-07T06:22:59.175074Z 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended.
  6. 2024-05-07T06:23:01.261487Z 6 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: jgR;k1H4Wa!f
  7. 2024-05-07T06:23:04.365176Z 0 [System] [MY-015018] [Server] MySQL Server Initialization - end.

        第四步,将mysql.server添加为系统服务,并启动mysql服务

  1. [root@vm-3rd89n7dd mysql]# cp support-files/mysql.server /etc/init.d/mysql.server
  2. [root@vm-3rd89n7dd mysql]# chkconfig --add mysql.server
  3. [root@vm-3rd89n7dd mysql]# systemctl start mysql.server
  4. [root@vm-3rd89n7dd mysql]# systemctl status mysql.server
  5. ● mysql.server.service - LSB: start and stop MySQL
  6. Loaded: loaded (/etc/rc.d/init.d/mysql.server; bad; vendor preset: disabled)
  7. Active: active (exited) since 二 2024-05-07 14:28:58 CST; 12s ago
  8. Docs: man:systemd-sysv-generator(8)
  9. Process: 4224 ExecStart=/etc/rc.d/init.d/mysql.server start (code=exited, status=0/SUCCESS)
  10. 507 14:28:58 vm-3rd89n7dd systemd[1]: Starting LSB: start and stop MySQL...
  11. 507 14:28:58 vm-3rd89n7dd mysql.server[4224]: Starting MySQL SUCCESS!
  12. 507 14:28:58 vm-3rd89n7dd systemd[1]: Started LSB: start and stop MySQL.
  13. 507 14:28:58 vm-3rd89n7dd mysql.server[4224]: 2024-05-07T06:28:58.247390Z mysqld_safe A mysqld process already exists

        第五步,修改临时密码

  1. [root@vm-3rd89n7dd ~]# mysqladmin -uroot -p'jgR;k1H4Wa!f' password 'YourPassword'
  2. mysqladmin: [Warning] Using a password on the command line interface can be insecure.
  3. Warning: Since password will be sent to server in plain text, use ssl connection to ensure password safety.

        如果不修改临时密码,并使用临时密码登录操作数据库,系统也会提示修改

  1. [root@vm-3rd89n7dd ~]# mysql -uroot -p
  2. Enter password:
  3. Welcome to the MySQL monitor. Commands end with ; or \g.
  4. Your MySQL connection id is 10
  5. Server version: 8.4.0-commercial
  6. Copyright (c) 2000, 2024, Oracle and/or its affiliates.
  7. Oracle is a registered trademark of Oracle Corporation and/or its
  8. affiliates. Other names may be trademarks of their respective
  9. owners.
  10. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
  11. mysql> show databases;
  12. ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.
  13. mysql> exit
  14. Bye

        第六步,为mysql设置环境变量,增加 /usr/local/mysql/bin 路径配置

  1. root@vm-3rd89n7dd ~]# vi .bash_profile
  2. # .bash_profile
  3. # Get the aliases and functions
  4. if [ -f ~/.bashrc ]; then
  5. . ~/.bashrc
  6. fi
  7. # User specific environment and startup programs
  8. JAVA_HOME=/usr/jdk1.8.0_411
  9. export JAVA_HOME
  10. CLASSPATH=.:$JAVA_HOME/lib:$JAVA_HOME/lib/tools.jar
  11. export CLASSPATH
  12. PATH=$JAVA_HOME/bin:$PATH:/usr/local/bin:/usr/local/mysql/bin:$HOME/bin
  13. export PATH
  14. [root@vm-3rd89n7dd ~]# source .bash_profile

        第七步,登录和操作数据库测试

  1. [root@vm-3rd89n7dd ~]# mysql -uroot -p
  2. Enter password:
  3. Welcome to the MySQL monitor. Commands end with ; or \g.
  4. Your MySQL connection id is 12
  5. Server version: 8.4.0-commercial MySQL Enterprise Server - Commercial
  6. Copyright (c) 2000, 2024, Oracle and/or its affiliates.
  7. Oracle is a registered trademark of Oracle Corporation and/or its
  8. affiliates. Other names may be trademarks of their respective
  9. owners.
  10. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
  11. mysql> show databases;
  12. +--------------------+
  13. | Database |
  14. +--------------------+
  15. | information_schema |
  16. | mysql |
  17. | performance_schema |
  18. | sys |
  19. +--------------------+
  20. 4 rows in set (0.01 sec)
  21. mysql> exit
  22. Bye

        以上就是MySQL 8.4.0 LTS版本安装、运行的一个基本过程(注意:过程中并未涉及数据库的详细配置,需要的可以在安装过程中自行添加相关配置)。

参考:

https://dev.mysql.com/doc/refman/8.4/en/binary-installation.html

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

闽ICP备14008679号