[root@node01 ~]# cat >> /etc/hosts <<EOF
192.168.1.101 node01
EOF
[root@node01 ~]# useradd mysql
[root@node01~]# echo mysql | passwd --stdin mysql
Changing password for user mysql.
passwd: all authentication tokens updated successfully.
[root@node01 ~]# id mysql
uid=1000(mysql) gid=1000(mysql) groups=1000(mysql)
[root@node01 ~]# cat >> /etc/security/limits.conf <<EOF
mysql soft nofile 4096
mysql hard nofile 65535
EOF
[root@node01 ~]# cat /sys/block/sda/queue/scheduler
noop [deadline] cfq
[root@node01 ~]# echo "vm.swappiness = 10" >>/etc/sysctl.conf
[root@node01 ~]# echo 'vm.dirty_background_ratio = 5' >>/etc/sysctl.conf
[root@node01 ~]# echo 'vm.dirty_ratio = 10' >>/etc/sysctl.conf
[root@node01 ~]# sysctl -p
[root@node01 ~]# yum install -y libaio
[root@node01 ~]# wget https://downloads.mysql.com/archives/get/p/23/file/mysql-8.0.32-linux-glibc2.12-x86_64.tar.xz
[root@node01 ~]# tar xvf mysql-8.0.32-linux-glibc2.12-x86_64.tar.xz
[root@node01 ~]# mv mysql-8.0.32-linux-glibc2.12-x86_64 mysql
[root@node01 ~]# mv mysql /usr/local/
[root@node01 ~]# mkdir /usr/local/mysql/data
[root@node01 ~]# chown -R mysql:mysql /usr/local/mysql
[root@node01 ~]# mkdir /var/lib/mysql
[root@node01 ~]# chown -R mysql:mysql /var/lib/mysql
[root@node01 ~]# mkdir /var/lib/mysql-files
[root@node01 ~]# chown mysql:mysql /var/lib/mysql-files
[root@node01 ~]# chmod 700 /var/lib/mysql-files
[root@node01 ~]# echo 'export PATH=$PATH:/usr/local/mysql/bin'>>/etc/profile
[root@node01 ~]# source /etc/profile
[root@node01 ~]# env | grep PATH
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin:/usr/local/mysql/bin
[root@node01 ~]# vim /etc/my.cnf
[mysqld]
user = mysql
port = 3306
basedir=/usr/local/mysql
datadir=/usr/local/mysql/data
socket=/var/lib/mysql/mysql.sock
secure_file_priv = /var/lib/mysql-files
pid-file=mysqld.pid
character_set_server=utf8mb4
transaction_isolation=REPEATABLE-READ
default_time_zone = "+8:00"
default_authentication_plugin=caching_sha2_password
default_storage_engine=InnoDB
max_connections=500
max_connect_errors=10000
wait_timeout=28800
interactive_timeout=28800
open_files_limit=65535
max_allowed_packet=64M
tmp_table_size=512M
max_heap_table_size=512M
log-error = mysqld_error.log
slow_query_log=on
slow_query_log_file=mysqld_slow.log
long_query_time=2
log_timestamps = SYSTEM
log_output = FILE,TABLE
server_id=101
log_bin=mysql-bin
binlog_format = row
binlog_cache_size=16M
binlog_row_image = full
binlog_expire_logs_seconds=2592000
binlog_rows_query_log_events=on
max_binlog_size=128M
sync_binlog = 1
relay_log = relay-bin
relay_log_recovery=on
innodb_buffer_pool_size=8GB
innodb_buffer_pool_instances=8
innodb_redo_log_capacity=2GB
innodb_log_buffer_size=16M
innodb_max_undo_log_size=1GB
innodb_undo_log_truncate=on
innodb_data_file_path=ibdata1:1024M:autoextend
innodb_temp_data_file_path=ibtmp1:128M:autoextend
[mysql]
socket=/var/lib/mysql/mysql.sock
prompt=(\\u@\\h) >\\_
[root@node01 ~]# chown mysql:mysql /etc/my.cnf
[root@node01 ~]# mysqld --initialize
[root@node01 ~]# cat /usr/local/mysql/data/mysqld_error.log | grep password
2023-05-30T13:34:58.339962+08:00 6 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: =frL7)R.MYzk
[root@node01 ~]# cp /usr/local/mysql/support-files/mysql.server /etc/init.d/
[root@node01 ~]# /etc/init.d/mysql.server start
[root@node01 ~]# /etc/init.d/mysql.server status
[root@node01 ~]# echo "/usr/local/mysql/lib" > /etc/ld.so.conf.d/mysql.conf
[root@node01 ~]# ldconfig
[root@node01 ~]# ln -s /usr/local/mysql/include/ /usr/include/mysql
[root@node01 ~]# ln -s /var/lib/mysql/mysql.sock /tmp/mysql.sock
[root@node01 ~]# mysql_secure_installation --no-defaults
Securing the MySQL server deployment.
Enter password for user root:
The existing password for the user account root has expired. Please set a new password.
New password:
Re-enter new password:
VALIDATE PASSWORD PLUGIN can be used to test passwords
and improve security. It checks the strength of password
and allows the users to set only those passwords which are
secure enough. Would you like to setup VALIDATE PASSWORD plugin?
Press y|Y for Yes, any other key for No:
Using existing password for root.
Change the password for root ? ((Press y|Y for Yes, any other key for No) :
Remove anonymous users? (Press y|Y for Yes, any other key for No) : y
Success.
Disallow root login remotely? (Press y|Y for Yes, any other key for No) : y
Success.
Remove test database and access to it? (Press y|Y for Yes, any other key for No) : y
- Dropping test database...
Success.
- Removing privileges on test database...
Success.
Reload privilege tables now? (Press y|Y for Yes, any other key for No) : y
Success.
All done!
[root@node01 ~]# mysql -uroot -pabcd.1234
(root@localhost) > select version();
+-----------+
| version() |
+-----------+
| 8.0.32 |
+-----------+
1 row in set (0.00 sec)
(root@localhost) > create user 'root'@'%' identified with caching_sha2_password by 'abcd.1234';
Query OK, 0 rows affected (0.02 sec)
(root@localhost) > grant all privileges on *.* to 'root'@'%' with grant option;
Query OK, 0 rows affected (0.02 sec)
(root@localhost) > flush privileges;
Query OK, 0 rows affected (0.04 sec)
[root@node01 ~]# mysql -uroot -pabcd.1234 -hnode01
(root@node01) > show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| sys |
+--------------------+
4 rows in set (0.01 sec)
标签:8.0,node01,log,local,7.5,usr,mysql,MySQL,root
From: https://blog.51cto.com/dbprofessional/7226460