随手写的,不喜请绕过
下载
wget -c http:
解压
tar -xf mysql-8.0.26-linux-glibc2.12-x86_64.tar.xz -C /usr/local/
ln -s /usr/local/mysql-8.0.26-linux-glibc2.12-x86_64 /usr/local/mysql
cd /usr/local/mysql vim my.cnf 根据需求自己定义
[mysqld]
basedir = /usr/local/mysql
port = 3306
server_id = 2
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
log-bin-index = master-bin.index
log-bin = mysql-bin
binlog-format = ROW
expire_logs_days = 3
max_connections = 5000
open_files_limit = 263154
sync_binlog = 500
innodb_flush_log_at_trx_commit = 2
wait_timeout = 1000
interactive_timeout = 1000
group_concat_max_len = 200000
binlog_checksum = none
character_set_server = utf8
log_error = /var/log/mysql/error.log
long_query_time=2
slow-query-log=On
slow_query_log_file="mysql_slow_query.log"
log_queries_not_using_indexes=off
groupadd mysql
useradd -s /sbin/nologin -r -g mysql mysql
cp -r support-files/mysql.server /etc/init.d/mysqld
chmod a+x /etc/init.d/mysqld
mkdir -p /data/mysql
chown -R mysql. /data/mysql
mkdir -p /var/log/mysql
chown -R mysql:mysql /var/log/mysql/
cat /etc/init.d/mysqld |cat -n|sed -n ‘46,47p’
46 basedir=/usr/local/mysql
47 datadir=/data/mysql
初始化 [root@localhost mysql]# /usr/local/mysql/bin/mysqld --initialize-insecure --user=mysql --datadir=/data/mysql/ --basedir=/usr/local/mysql/
2022-04-06T09:49:10.215275Z 0 [System] [MY-013169] [Server] /usr/local/mysql/bin/mysqld (mysqld 8.0.26) initializing of server in progress as process 7563
2022-04-06T09:49:10.223532Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started.
2022-04-06T09:49:11.127851Z 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended.
2022-04-06T09:49:12.426474Z 0 [Warning] [MY-013746] [Server] A deprecated TLS version TLSv1 is enabled for channel mysql_main
2022-04-06T09:49:12.426956Z 0 [Warning] [MY-013746] [Server] A deprecated TLS version TLSv1.1 is enabled for channel mysql_main
2022-04-06T09:49:12.466538Z 6 [Warning] [MY-010453] [Server] root@localhost is created with an empty password ! Please consider switching off the --initialize-insecure option.
[root@localhost mysql]# /usr/local/mysql/bin/mysql -uroot -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 84
Server version: 8.0.26 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>
mysql> use mysql
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Database changed
mysql> alter user 'root'@'localhost' identified by '123456';
Query OK, 0 rows affected (0.01 sec)
-----------end
|