# 添加mysql用户[root@centos76mysql57 /]# useradd mysql[root@centos76mysql57 opt]# ls -lth
total 631M
-rw-r--r--. 1 root root 631M Sep 413:44 mysql-5.7.32-linux-glibc2.12-x86_64.tar.gz
# 解压文件[root@centos76mysql57 opt]# tar -zxvf mysql-5.7.32-linux-glibc2.12-x86_64.tar.gz[root@centos76mysql57 opt]# mv mysql-5.7.32-linux-glibc2.12-x86_64 /usr/local/mysql[root@centos76mysql57 opt]# cd /usr/local/[root@centos76mysql57 local]# ls
bin etc games include lib lib64 libexec mysql sbin share src
[root@centos76mysql57 local]# ls -lth
total 0
drwxr-xr-x. 9 root root 129 Oct 216:12 mysql
drwxr-xr-x. 5 root root 49 Dec 42018 share
drwxr-xr-x. 2 root root 6 Apr 112018 bin
drwxr-xr-x. 2 root root 6 Apr 112018 etc
drwxr-xr-x. 2 root root 6 Apr 112018 games
drwxr-xr-x. 2 root root 6 Apr 112018 include
drwxr-xr-x. 2 root root 6 Apr 112018 lib
drwxr-xr-x. 2 root root 6 Apr 112018 lib64
drwxr-xr-x. 2 root root 6 Apr 112018 libexec
drwxr-xr-x. 2 root root 6 Apr 112018 sbin
drwxr-xr-x. 2 root root 6 Apr 112018 src
# 创建数据目录并赋予权限[root@centos76mysql57 local]# mkdir -p /data/mysql[root@centos76mysql57 local]# [root@centos76mysql57 local]# chown mysql:mysql -R /data/mysql# 配置环境变量[root@centos76mysql57 support-files]# vi /etc/profile export PATH=/usr/local/mysql/bin:$PATH[root@centos76mysql57 support-files]# source /etc/profile# 配置my.cnf [root@centos76mysql57 mysql]# vi /etc/my.cnf [root@centos76mysql57 mysql]# more /etc/my.cnf [mysqld]
bind-address=0.0.0.0
port=3306user=mysql
basedir=/usr/local/mysql
datadir=/data/mysql
socket=/tmp/mysql.sock
log-error=/data/mysql/mysql.err
pid-file=/data/mysql/mysql.pid
#character configcharacter_set_server=utf8mb4
symbolic-links=0explicit_defaults_for_timestamp=true# 初始化数据库[root@centos76mysql57 mysql]# cd /usr/local/mysql/[root@centos76mysql57 bin]# ./mysqld --defaults-file=/etc/my.cnf --basedir=/usr/local/mysql/ --datadir=/data/mysql/ --user=mysql --initialize
./mysqld: error while loading shared libraries: libnuma.so.1: cannot open shared object file: No such file or directory
[root@centos76mysql57 bin]# yum -y install numactl[root@centos76mysql57 bin]# ./mysqld --defaults-file=/etc/my.cnf --basedir=/usr/local/mysql/ --datadir=/data/mysql/ --user=mysql --initialize[root@centos76mysql57 bin]# cd /data/mysql/[root@centos76mysql57 mysql]# ls
auto.cnf client-cert.pem ib_logfile0 mysql private_key.pem server-key.pem
ca-key.pem client-key.pem ib_logfile1 mysql.err public_key.pem sys
ca.pem ib_buffer_pool ibdata1 performance_schema server-cert.pem
[root@centos76mysql57 mysql]# ls -lth
total 109M
-rw-r-----. 1 mysql mysql 12M Oct 216:24 ibdata1
-rw-r-----. 1 mysql mysql 48M Oct 216:24 ib_logfile0
-rw-r-----. 1 mysql mysql 431 Oct 216:24 ib_buffer_pool
drwxr-x---. 2 mysql mysql 8.0K Oct 216:24 sys
drwxr-x---. 2 mysql mysql 4.0K Oct 216:24 mysql
drwxr-x---. 2 mysql mysql 8.0K Oct 216:24 performance_schema
-rw-r-----. 1 mysql mysql 690 Oct 216:24 mysql.err
-rw-------. 1 mysql mysql 1.7K Oct 216:24 private_key.pem
-rw-r--r--. 1 mysql mysql 452 Oct 216:24 public_key.pem
-rw-r--r--. 1 mysql mysql 1.1K Oct 216:24 client-cert.pem
-rw-------. 1 mysql mysql 1.7K Oct 216:24 client-key.pem
-rw-r--r--. 1 mysql mysql 1.1K Oct 216:24 server-cert.pem
-rw-------. 1 mysql mysql 1.7K Oct 216:24 server-key.pem
-rw-r--r--. 1 mysql mysql 1.1K Oct 216:24 ca.pem
-rw-------. 1 mysql mysql 1.7K Oct 216:24 ca-key.pem
-rw-r-----. 1 mysql mysql 56 Oct 216:24 auto.cnf
-rw-r-----. 1 mysql mysql 48M Oct 216:24 ib_logfile1# 查看密码[root@centos76mysql57 mysql]# cat /data/mysql/mysql.err2022-10-02T16:24:51.682299Z 0[Warning] InnoDB: New log files created, LSN=457902022-10-02T16:24:51.708503Z 0[Warning] InnoDB: Creating foreign key constraint system tables.
2022-10-02T16:24:51.763628Z 0[Warning] No existing UUID has been found, so we assume that this is the first time that this server has been started. Generating a new UUID: bdde105f-426e-11ed-8906-0242ac110003.
2022-10-02T16:24:51.764563Z 0[Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
2022-10-02T16:24:52.159541Z 0[Warning] CA certificate ca.pem is self signed.
2022-10-02T16:24:52.389241Z 1[Note] A temporary password is generated for root@localhost: xor9k*ntt/,P# 启动数据库[root@centos76mysql57 support-files]# pwd
/usr/local/mysql/support-files
[root@centos76mysql57 mysql]# systemctl enable mysqld
mysqld.service is not a native service, redirecting to /sbin/chkconfig.
Executing /sbin/chkconfig mysqld on
[root@centos76mysql57 support-files]# ./mysql.server start
Starting MySQL. SUCCESS![root@centos76mysql57 support-files]# ./mysql.server stop
Shutting down MySQL.. SUCCESS![root@centos76mysql57 support-files]# cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld[root@centos76mysql57 support-files]# systemctl start mysqld[root@centos76mysql57 support-files]# systemctl status mysqld
● mysqld.service - LSB: start and stop MySQLLoaded: loaded (/etc/rc.d/init.d/mysqld; bad; vendor preset: disabled)Active: active (running) since Sun 2022-10-02 16:30:27 UTC; 4s agoDocs: man:systemd-sysv-generator(8)Process: 3989ExecStart=/etc/rc.d/init.d/mysqld start (code=exited, status=0/SUCCESS)CGroup: /system.slice/docker-6e3bac4fe05fec8287b9e660741026793319bc23b2ad879f067a9778a89ea7a6.scope/system.slice/mysqld.service├─4002 /bin/sh /usr/local/mysql/bin/mysqld_safe --datadir=/data/mysql --pid-file=/data/mysql/mysql.pid└─4229 /usr/local/mysql/bin/mysqld --basedir=/usr/local/mysql --datadir=/data/mysql --plugin-dir=/usr/local/...Oct 02 16:30:26 centos76mysql57 systemd[1]: Starting LSB: start and stop MySQL...
Oct 02 16:30:27 centos76mysql57 mysqld[3989]: Starting MySQL. SUCCESS!
Oct 02 16:30:27 centos76mysql57 systemd[1]: Started LSB: start and stop MySQL.# 修改密码[root@centos76mysql57 support-files]# mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 6
Server version: 5.7.32Copyright (c)2000, 2020, Oracle and/or its affiliates. All rights reserved.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 by '123456';
Query OK, 0 rows affected (0.00 sec)