tar -xzvf mysql-5.7.28-linux-glibc2.12-x86_64.tar.gz
mv mysql-5.7.28-linux-glibc2.12-x86_64 /usr/local/mysql
groupadd mysql
useradd -r -g mysql mysql
mkdir /usr/local/mysql/data
mkdir /usr/local/mysql/log
touch /usr/local/mysql/mysqld.pid
touch /usr/local/mysql/log/mysql-bin.index
cd /usr/local/mysql
chown -R mysql:mysql ./
chown -R mysql:mysql data
bin/mysqld --initialize --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data
出现报错bin/mysqld: error while loading shared libraries: libaio.so.1: cannot open shared object file: No such file or directory
解决方法 yum install -y libaio
日志中出现A temporary password 后面为默认密码
cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld
编辑:/etc/my.cnf
service mysqld start
chkconfig --add mysqld #设置开机自启
#service mysqld restart
#service mysqld stop
ln -s /usr/local/mysql/bin/mysql /usr/bin
mysql -h127.0.0.1 -uroot -p
mysql> set password= password('root');
#mysql> GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'root' WITH GRANT OPTION;
SHOW VARIABLES WHERE Variable_name LIKE 'character\_set\_%' OR Variable_name LIKE 'collation%'; #验证字符集
/etc/my.cnf
[client]
default-character-set = utf8mb4
[mysql]
default-character-set = utf8mb4
[mysqld]
character-set-client-handshake = FALSE
character-set-server = utf8mb4
collation-server = utf8mb4_unicode_ci
basedir = /usr/local/mysql
datadir = /usr/local/mysql/data
socket = /usr/local/mysql/mysql.sock
port = 3306
log-error = /var/log/mysqld.log
pid-file= /usr/local/mysql/mysqld.pid
tmpdir = /tmp
user = mysql
log-bin = /usr/local/mysql/log/mysql-bin
server-id = 1
binlog-format = row
log-slave-updates = true
enforce-gtid-consistency = true
gtid-mode = on
sql_mode=STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION
网友评论