[root@localhost src]# groupadd -r mysql[root@localhost src]# useradd -M -s /sbin/nologin -g mysql mysql
3. 解压安装包,创建数据目录,授权
//解压
[root@localhost src]# tar xf mysql-8.0.20-el7-x86_64.tar.gz -C /usr/local/[root@localhost src]# cd /usr/local/[root@localhost local]# ls
bin etc games include lib lib64 libexec mysql-8.0.20-el7-x86_64 sbin share src
[root@localhost mysql]# pwd
/usr/local/mysql
[root@localhost mysql]# ./bin/mysqld --initialize --user=mysql --basedir=/usr/local/mysql --datadir=/opt/data --lower-case-table-names=12023-04-24T06:46:34.319067Z 0[Warning][MY-011070][Server]'Disabling symbolic links using --skip-symbolic-links (or equivalent) is the default. Consider not using this option as it' is deprecated and will be removed in a future release.
2023-04-24T06:46:34.319155Z 0[System][MY-013169][Server] /usr/local/mysql-8.0.20-el7-x86_64/bin/mysqld (mysqld 8.0.20) initializing of server in progress as process 17412023-04-24T06:46:34.336241Z 1[System][MY-013576][InnoDB] InnoDB initialization has started.
2023-04-24T06:46:35.137438Z 1[System][MY-013577][InnoDB] InnoDB initialization has ended.
2023-04-24T06:46:36.121012Z 6[Note][MY-010454][Server] A temporary password is generated for root@localhost: ht1uVqbMX4/t
注意密码在最后 ht1uVqbMX4/t
//修改密码,默认密码在初始化的时候已经生成
[root@localhost local]# mysql -uroot -p
Enter password: ht1uVqbMX4/t
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 8
Server version: 8.0.20
Copyright (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>
mysql> ALTER USER'root'@'localhost' IDENTIFIED BY '1';
Query OK, 0 rows affected (0.00 sec)