wget https://dev.mysql.com/get/Downloads/MySQL-8.0/mysql-8.0.33-linux-glibc2.12-x86_64.tar.xz
使用 命令查找mysql数据库软件包及依赖包,若没有任何显示则证明没有相关的mysql数据库
rpm -qa | grep mysql #查找mysql
rpm -e --nodeps mysql-libs-5.5.65-1.el7.x86_64 #删除mysql
rm -rf /etc/my.cnf #删除my.cnf文件,防止配置文件冲突
rpm -qa | grep mariadb #查找mysql
rpm -e --nodeps mariadb-libs-5.5.65-1.el7.x86_64 #删除mysql
#解压
tar -xvf mysql-8.0.33-linux-glibc2.12-x86_64.tar.xz -C /usr/local
mv /usr/local/mysql-8.0.33-linux-glibc2.12-x86_64 /usr/local/mysql
groupadd mysql #添加mysql组
useradd -g mysql mysql -s /bin/false #不允许mysql用户直接登录系统
mkdir -p /web/data/mysql #创建MySQL数据库存放目录
vi /usr/local/mysql/my.cnf
[client]
port = 3306
default-character-set = utf8mb4
[mysqld]
port = 3306
basedir = /usr/local/mysql
datadir = /web/data/mysql
init-connect = 'SET NAMES utf8mb4'
#将mysql目录的权限授给mysql用户和mysql组
chown -R mysql:mysql /usr/local/mysql
chown -R mysql:mysql /web/data/mysql
ln -s /usr/local/mysql/my.cnf /etc/my.cnf #添加到/etc目录的软连接
cd /usr/local/mysql #进入MySQL安装目录
./bin/mysqld --user=mysql --initialize --basedir=/usr/local/mysql --datadir=/web/data/mysql #生成mysql系统数据库
ln -s /usr/local/mysql/bin/mysql /usr/bin
cp /usr/local/mysql/support-files/mysql.server /etc/rc.d/init.d/mysqld #把Mysql加入系统启动
chmod 755 /etc/init.d/mysqld #增加执行权限
chkconfig mysqld on #加入开机启动
vi /etc/rc.d/init.d/mysqld #编辑
basedir=/usr/local/mysql #MySQL程序安装路径
datadir=/web/data/mysql #MySQl数据库存放目录
service mysqld start #启动
mysql -uroot -p
set PASSWORD = 'password123456';
flush privileges;
修改加密规则Navicat 登录
use mysql;
ALTER USER 'root'@'localhost' IDENTIFIED BY 'password' PASSWORD EXPIRE NEVER;
//更新一下用户的密码(可以直接复制)
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'password';
flush privileges; //刷新生效