mysql-8.0.27-linux-glibc2.12-x86_64.tar.xz -》/opt/mysql8
mkdir /opt/mysql8/log
mkdir /opt/mysql8/data
rm -rf /etc/my.cnf
vim /opt/mysql8/my.cnf
[mysqld]
port=3306
datadir=/opt/mysql8/data
log_error=/opt/mysql8/log/error.log
character_set_server=utf8mb4
collation_server=utf8mb4_unicode_ci
创建mysql用户并赋权目录
useradd mysql
chown -R mysql:mysql /opt/mysql8
安装前置软件
yum -y install java pcre-devel zlib-devel perl-Data-Dumper
初始化:
sudo -u mysql /opt/mysql8/bin/mysqld --defaults-file=/opt/mysql8/my.cnf --initialize
查看初始化密码:
cat /opt/mysql8/log/error.log | grep local
启动:
sudo -u mysql /opt/mysql8/bin/mysqld --defaults-file=/opt/mysql8/my.cnf &
登录:
/opt/mysql8/bin/mysql -uroot -p
修改密码:
ALTER USER 'root'@'localhost' IDENTIFIED BY 'root';
退出重新登陆
允许root远程登陆:
CREATE USER 'root'@'%' IDENTIFIED BY 'root';
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' WITH GRANT OPTION;
FLUSH PRIVILEGES;