Skip to content

Instantly share code, notes, and snippets.

@gotnix
Created April 26, 2020 07:07
Show Gist options
  • Save gotnix/868934e6655f156451d8775424362464 to your computer and use it in GitHub Desktop.
Save gotnix/868934e6655f156451d8775424362464 to your computer and use it in GitHub Desktop.
test.adoc

MySQL 初始化

首选的安全初始化

Initialize Secure
cd /opt/app/mysql
# 酌情调整监听地址,InnoDB Buffer Poll 大小等配置
vim 3306/etc/my.cnf

# 初始化
./bin/mysqld --defaults-file=3306/etc/my.cnf --initialize

# 启动服务
systemctl start 2345-mysql-3306

# 查看初始化密码
grep 'temporary password' 3306/logs/error_mysqld.log

# 登录 MySQL
./bin/mysql --defaults-file=3306/etc/my.cnf -uroot
ALTER USER IF EXISTS 'root'@'localhost' IDENTIFIED BY '{PASSWD}'

Initialize Insecure

不提倡的非安全初始化

Initialize Insecure
cd /opt/app/mysql
# 酌情调整监听地址,InnoDB Buffer Poll 大小等配置
vim 3306/etc/my.cnf

# 初始化
./bin/mysqld --defaults-file=./3306/etc/my.cnf --initialize-insecure

# 启动服务
systemctl start 2345-mysql-3306

# 登录 MySQL
./bin/mysql --defaults-file=3306/etc/my.cnf -uroot
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment