Install
Configure
初始化
# MYSQL_HOME=/path/of/mysql DATA_DIR=/path/of/mysql/data
$MYSQL_HOME/bin//mysqld --initialize --datadir=$DATA_DIR
- 在日志中找到用户和临时密码
2024-11-26T06:37:28.511947Z 6 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: afNP,gjia1w(
配置
- 服务器配置
[mysqld]
server-id=1
bind-address=0.0.0.0
port=3306
datadir=/Users/tts/Apps/mysql/data
tmpdir=/Users/tts/Apps/mysql/temp
pid-file=/Users/tts/Apps/mysql/temp/mysql.pid
character-set-server=utf8mb4
collation-server=utf8mb4_unicode_ci
default-time-zone=+8:00
log-bin=mysql-bin
log-bin-index=mysql-bin.index
relay-log=relay-log
relay_log_index=relay-log.index
log-error=/Users/tts/Apps/mysql/log/mysql.err.log
slow_query_log=on
long_query_time=10
slow_query_log_file=/Users/tts/Apps/mysql/log/mysql.slow.log
innodb_use_native_aio=0
[mysqldump]
quick
max_allowed_packet=16M
[mysql]
default-character-set=utf8mb4
no-auto-rehash
- 启动脚本
#!/bin/sh
basedir=/Users/tts/Apps/mysql
logdir="$basedir/log"
nohup $basedir/bin/mysqld_safe --defaults-file="$basedir/conf/my.conf" > $logdir/mysql.log 2>&1 &
- 更新用户密码
DELETE FROM `mysql`.`user` WHERE `Host` = 'localhost' AND `User` <> 'root';
ALTER USER 'root'@'localhost' IDENTIFIED WITH caching_sha2_password BY '123456';