文档课题:MySQL 8.0.27安装.
系统:rhel 7.3
安装包:mysql-8.0.27-linux-glibc2.17-x86_64-minimal.tar.xz
1、获取glibc版本
[root@leo-827mgr-master ~]# ldd --version
ldd (GNU libc) 2.17
Copyright (C) 2012 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Written by Roland McGrath and Ulrich Drepper.
说明:根据glibc版本,选择下载不同的安装包,下载地址:https://dev.mysql.com/downloads
2、安装
2.1、创建目录和用户
[root@leo-827mgr-master ~]# useradd mysql
[root@leo-827mgr-master ~]# echo "mysql_4U" | passwd mysql --stdin
[root@leo-827mgr-master ~]# mkdir -p /mysql/data
[root@leo-827mgr-master ~]# mkdir -p /mysql/binlog
[root@leo-827mgr-master ~]# mkdir -p /opt/mysql
[root@leo-827mgr-master ~]# mkdir -p /opt/logs
[root@leo-827mgr-master ~]# chown -R mysql:mysql /mysql/
[root@leo-827mgr-master ~]# chown -R mysql:mysql /opt
[root@leo-827mgr-master ~]# su - mysql
[mysql@leo-827mgr-master ~]$ mkdir etc
2.2、文件处理
sftp> lcd F:\installmedium\mysql\MySQL-8.0.27
sftp> put mysql-8.0.27-linux-glibc2.17-x86_64-minimal.tar.xz
[root@leo-827mgr-master ~]# chown mysql:mysql mysql-8.0.27-linux-glibc2.17-x86_64-minimal.tar.xz
[root@leo-827mgr-master ~]# mv mysql-8.0.27-linux-glibc2.17-x86_64-minimal.tar.xz /opt
[root@leo-827mgr-master ~]# su - mysql
[mysql@leo-827mgr-master ~]$ cd /opt
[mysql@leo-827mgr-master opt]$ tar -xf mysql-8.0.27-linux-glibc2.17-x86_64-minimal.tar.xz
[mysql@leo-827mgr-master opt]$ exit
[root@leo-827mgr-master ~]# cd /opt/mysql-8.0.27-linux-glibc2.17-x86_64-minimal/support-files
[root@leo-827mgr-master support-files]# cp -p mysql.server /etc/init.d/
[root@leo-827mgr-master support-files]# chmod +x /etc/init.d/mysql.server
[root@leo-827mgr-master support-files]# su - mysql
[mysql@leo-827mgr-master ~]$ cd etc
[mysql@leo-827mgr-master etc]$ vim my.cnf
添加如下:
[mysqld]
user=mysql
port=3306
socket=/mysql/data/mysql.sock
pid_file=/mysql/data/mysql.pid
server_id=1
basedir=/opt/mysql
datadir=/mysql/data/
log_bin=/mysql/binlog/mysql-bin
log_bin_index=/mysql/binlog/mysql-bin.index
gtid_mode=ON
enforce_gtid_consistency=ON
log-error=/opt/logs/mysql_error.log
innodb_buffer_pool_size=2G
[mysql]
no-auto-rehash
default-character-set=utf8mb4
show-warnings
prompt="(\u@\h) [\d] \R:\m:\\s \c> "
2.3、初始化数据库
[mysql@leo-827mgr-master etc]$ cd /opt/mysql-8.0.27-linux-glibc2.17-x86_64-minimal/bin
[mysql@leo-827mgr-master bin]$ ./mysqld --defaults-file=/home/mysql/etc/my.cnf --initialize-insecure
2.4、开启数据库
[mysql@leo-827mgr-master bin]$ cd
[mysql@leo-827mgr-master ~]$ vim .bash_profile
# .bash_profile
# Get the aliases and functions
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi
# User specific environment and startup programs
PATH=$PATH:$HOME/.local/bin:$HOME/bin
export PATH
export PATH=/opt/mysql-8.0.27-linux-glibc2.17-x86_64-minimal/bin:$PATH
[mysql@leo-827mgr-master ~]$ source .bash_profile
[mysql@leo-827mgr-master ~]$ mysqld_safe --defaults-file=/home/mysql/etc/my.cnf &
[1] 46089
[mysql@leo-827mgr-master ~]$ 2023-09-29T15:24:18.415624Z mysqld_safe Logging to '/opt/logs/mysql_error.log'.
2023-09-29T15:24:18.446840Z mysqld_safe Starting mysqld daemon with databases from /mysql/data
[mysql@leo-827mgr-master ~]$ ps -ef | grep mysql
root 12823 12578 0 22:45 pts/2 00:00:00 su - mysql
mysql 12824 12823 0 22:45 pts/2 00:00:00 -bash
root 45869 13325 0 23:14 pts/1 00:00:00 su - mysql
mysql 45870 45869 0 23:14 pts/1 00:00:00 -bash
mysql 46089 45870 0 23:24 pts/1 00:00:00 /bin/sh /opt/mysql-8.0.27-linux-glibc2.17-x86_64-minimal/bin/mysqld_safe --defaults-file=/home/mysql/etc/my.cnf
mysql 46314 46089 39 23:24 pts/1 00:00:03 /opt/mysql-8.0.27-linux-glibc2.17-x86_64-minimal/bin/mysqld --defaults-file=/home/mysql/etc/my.cnf --basedir=/opt/mysql --datadir=/mysql/data --plugin-dir=/usr/local/mysql/lib/plugin --log-error=/opt/logs/mysql_error.log --pid-file=/mysql/data/mysql.pid --socket=/mysql/data/mysql.sock --port=3306
mysql 46371 45870 0 23:24 pts/1 00:00:00 ps -ef
mysql 46372 45870 0 23:24 pts/1 00:00:00 grep --color=auto mysql
2.5、修改密码
[mysql@leo-827mgr-master ~]$ mysql -uroot -p -P 3306 -h 127.0.0.1
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 8
Server version: 8.0.27 MySQL Community Server - GPL
Copyright (c) 2000, 2021, 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> select user,host from mysql.user;
+------------------+-----------+
| user | host |
+------------------+-----------+
| mysql.infoschema | localhost |
| mysql.session | localhost |
| mysql.sys | localhost |
| root | localhost |
+------------------+-----------+
4 rows in set (0.00 sec)
mysql> alter user 'root'@'localhost' identified with mysql_native_password by 'mysql_4U';
Query OK, 0 rows affected (0.00 sec)
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
标签:8.0,00,27,827mgr,leo,master,mysql,MySQL,root
From: https://blog.51cto.com/u_12991611/7675185