[root@MySQL ~]# cat /etc/redhat-release
CentOS Linux release 8.5.2111
官网下载地址:MySQL :: Download MySQL Community Server (Archived Versions)
[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
[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
[root@MySQL local]# groupadd mysql
[root@MySQL local]# useradd -r -g mysql mysql
[root@MySQL local]# groups mysql
mysql : 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
………………
[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
[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/
[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
[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
[root@MySQL mysql-8.0.33]# service mysql start
Starting MySQL.. SUCCESS!
[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 //默认密码
……………………
[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)
[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 搭建成功