MySQL 5.7.7以上二进制包就不包括原data目录的初始化系统表,官网说明:
http://dev.mysql.com/doc/refman/5.7/en/data-directory-initialization-mysql-install-db.html
2016年4月中MySQL官方最新的5.7稳定版本是5.7.12,之前常用5.5版本。
初始化过程:
[[email protected]_d10014787 mysql]# tar -zxvf mysql-5.7.12-linux-glibc2.5-x86_64.tar.gz [[email protected]_d10014787 mysql]# cp -r mysql-5.7.12-linux-glibc2.5-x86_64 /usr/local/mysql57 [[email protected]_d10014787 mysql]# cd /usr/local/mysql57 [[email protected]_d10014787 mysql]# ./bin/mysqld --defaults-file=/etc/my_5712.cnf --initialize --user=mysql 或 [[email protected]_d10014787 mysql]# ./bin/mysqld --datadir=/data/mysql/5712_test --basedir=/usr/local/mysql57 --initialize --user=mysql 注意初始化完会在errlog中写入一行,有初始化的[email protected]密码 [Note] A temporary password is generated for [email protected]: r.o.pz8p*r>P [[email protected]_d10014787 mysql]# chown -R mysql.mysql /data/mysql/5712_test [[email protected]_d10014787 mysql]# ./bin/mysqld_safe --defaults-file=/etc/my_5712.cnf & [[email protected]_d10014787 mysql]# ./bin/mysql -uroot -p -S mysql.sock 进行任何操作必须先重置root密码 mysql> alter user [email protected] identified by ‘123‘;
个人感觉这样初始化在自动化部署时增加了难度...
时间: 2024-11-05 19:25:13