2.1 解压
# tar -xvf mysql-8.0.23-linux-glibc2.12-x86_64.tar.xz
解压命令如报以下错误,请安装组件
# tar -xvf mysql-8.0.23-linux-glibc2.12-x86_64.tar.xztar(child): xz: Cannot exec: No such file or directory
tar(child): Error is not recoverable: exiting now
tar: Child returned status 2
tar: Error is not recoverable: exiting now
# yum install -y xz
2.2 将解压的文件重命名mysql,并移动到/usr/local目录下
# mv mysql-8.0.23-linux-glibc2.12-x86_64 mysql# mv mysql /usr/local/
3. 创建用户和用户组并授权
# cd /usr/local/# groupadd mysql# useradd -r -g mysql mysql# cd mysql/ #注意:进入mysql文件下授权所有的文件# chown -R mysql:mysql ./
8.1 登录
# mysql -u root -p
输入步骤4.2中保存的密码
8.2 修改密码
mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY '新密码';
8.3 开启远程登陆
ALTER USER USER() IDENTIFIED BY 'root';
8.4 修改配置
mysql> use mysql;
#查看用户信息
mysql> select host, user, authentication_string, plugin from user;
#授权root用户可以远程登陆
mysql> GRANT ALL ON *.* TO 'root'@'%';
#立即生效
mysql> flush privileges;
#修改root用户在任何情况下登录的密码
mysql> ALTER USER 'root'@'%' IDENTIFIED WITH mysql_native_password BY '新密码';
#立即生效
mysql> FLUSH PRIVILEGES;
#退出
mysql> exit;
8.5 重启mysql服务
# service mysql restart