Zabbix 学习(一)源码安装MySQL 8.0.33版本数据库

一、安装前提

1、检查操作系统的版本:

[root@MySQL ~]# cat /etc/redhat-release
CentOS Linux release 8.5.2111

2、准备所需要的MySQ安装版本:MySQL 8.0.33

官网下载地址:MySQL :: Download MySQL Community Server (Archived Versions)

Zabbix 学习(一)源码安装MySQL 8.0.33版本数据库_第1张图片

 二、安装

 1、将安装包通过远程工具上传至服务器并解压到目标安装目录:/root

[root@MySQL ~]# ls
anaconda-ks.cfg  mysql-8.0.33-linux-glibc2.12-x86_64.tar

[root@MySQL ~]# tar -vxf mysql-8.0.33-linux-glibc2.12-x86_64.tar
mysql-test-8.0.33-linux-glibc2.12-x86_64.tar.xz
mysql-8.0.33-linux-glibc2.12-x86_64.tar.xz
mysql-router-8.0.33-linux-glibc2.12-x86_64.tar.xz

[root@MySQL ~]# tar -vxf mysql-8.0.33-linux-glibc2.12-x86_64.tar.xz -C /usr/local/
mysql-8.0.33-linux-glibc2.12-x86_64/bin/
mysql-8.0.33-linux-glibc2.12-x86_64/bin/myisam_ftdump
mysql-8.0.33-linux-glibc2.12-x86_64/bin/myisamchk
mysql-8.0.33-linux-glibc2.12-x86_64/bin/myisamlog
mysql-8.0.33-linux-glibc2.12-x86_64/bin/myisampack

……………………

mysql-8.0.33-linux-glibc2.12-x86_64/share/
mysql-8.0.33-linux-glibc2.12-x86_64/share/install_rewriter.sql
mysql-8.0.33-linux-glibc2.12-x86_64/share/uninstall_rewriter.sql
[root@MySQL ~]# ls /usr/local/
bin  etc  games  include  lib  lib64  libexec  mysql-8.0.33-linux-glibc2.12-x86_64  sbin  share  src

2、修改文件名 mysql-8.0.33-linux-glibc2.12-x86_64 为 mysql-8.0.33

[root@MySQL local]# mv mysql-8.0.33-linux-glibc2.12-x86_64/ mysql-8.0.33
[root@MySQL local]# ls
bin  etc  games  include  lib  lib64  libexec  mysql-8.0.33  sbin  share  src

3、增加用户组并在用户组下增加用户

[root@MySQL local]# groupadd mysql
[root@MySQL local]# useradd -r -g mysql mysql
[root@MySQL local]# groups mysql
mysql : mysql

4、修改安装目录 /usr/local/mysql-8.0.33/ 的所有者及所属组改为 mysql

[root@MySQL local]# chown -R mysql:mysql /usr/local/mysql-8.0.33
………………
drwxr-xr-x  9 mysql mysql 129 7月  25 10:21 mysql-8.0.33
………………

5、修改配置文件 my.cnf,增加配置,设置编码格式及忽略大小写

[mysqld]
basedir=/usr/local/mysql-8.0.33
datadir=/usr/local/mysql-8.0.33/data
port=3306
socket=/tmp/mysql.sock
character_set_server=utf8
lower_case_table_names=1
log-error=/usr/local/mysql-8.0.33/data/mysql.log
pid-file=/usr/local/mysql-8.0.33/data/mysql.pid
[mysql]
default-character-set = utf8

6、在 mysql-8.0.33 目录下创建一个 data 文件夹,进行初始化配置

[root@MySQL mysql-8.0.33]# mkdir data
[root@MySQL mysql-8.0.33]# ./bin/mysqld --initialize --user=mysql --basedir=/usr/local/mysql-8.0.33/ --datadir=/usr/local/mysql-8.0.33/data/

7、将mysql加入到可控制启动服务的文件夹内,并命名mysql(service可控制的服务名)

[root@MySQL mysql-8.0.33]# cd support-files/
[root@MySQL support-files]# ls
mysqld_multi.server  mysql-log-rotate  mysql.server
[root@MySQL support-files]# cp mysql.server /etc/init.d/mysql

8、配置环境变量

[root@MySQL support-files]# vim /etc/profile

//在文件的最底部添加

export MYSQL_HOME="/usr/local/mysql-8.0.33"
export PATH="$PATH:$MYSQL_HOME/bin"


[root@MySQL support-files]# source /etc/profile

9、启动MySQL,显示SUCCESS!

[root@MySQL mysql-8.0.33]# service mysql start
Starting MySQL.. SUCCESS!

三、登陆MySQL

1、查看默认密码

[root@MySQL mysql-8.0.33]# mysql -uroot -p
mysql: error while loading shared libraries: libtinfo.so.5: cannot open shared object file: No such file or directory

[root@MySQL ~]# ln -s /usr/lib64/libtinfo.so.6.1 /usr/lib64/libtinfo.so.5

[root@MySQL mysql-8.0.33]# mysql -uroot -p
Enter password:
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)

[root@MySQL mysql-8.0.33]# vim /usr/local/mysql-8.0.33/data/mysql.log
……………………
 2023-07-25T14:55:49.036035Z 6 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: NzFq7gecCO%0 //默认密码
……………………

2、修改密码

[root@MySQL mysql-8.0.33]# mysql -uroot -p'NzFq7gecCO%0'
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 9
Server version: 8.0.33

Copyright (c) 2000, 2023, 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> ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '密码';
Query OK, 0 rows affected (0.01 sec)

mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)

3、测试登陆

[root@MySQL mysql-8.0.33]# mysql -uroot -p'密码'
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 10
Server version: 8.0.33 MySQL Community Server - GPL

Copyright (c) 2000, 2023, 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 8.0.33 搭建成功

你可能感兴趣的:(Zabbix,学习介绍,mysql,数据库)