Centos7 安装Mysql8.0
程序员文章站
2024-03-21 16:50:04
...
1.wget下载mysql文件.tar.gz
wget https://cdn.mysql.com//Downloads/MySQL-8.0/mysql-8.0.11-el7-x86_64.tar.gz
2.卸载系统中mariadb,解压下载的源文件
//检查是否存在
yum list installed | grep mariadb
//卸载
yum -y remove mariadb-libs.x86_64
tar -xzvf mysql-8.0.11-el7-x86_64.tar.gz -C /usr/local/mysql
3.添加组和用户
groupadd mysql
useradd -g mysql mysql
4.安装
//安装,在/usr/local/mysql/bin目录下操作
./mysqld --initialize --user=mysql --datadir=/usr/local/mysql/data --basedir=/usr/local/mysql
记住初始随机密码,后面会用到
5.修改密码及远程访问
切换到/usr/local/mysql/bin目录下
./mysql_ssl_rsa_setup --datadir=/usr/local/mysql/data
chown -R mysql: mysql /usr/local/mysql
./mysqld_safe &
./mysql -uroot -p
`输入刚才密码即可以登录,默认不能远程`
//修改root密码
alter user 'root'@'localhost' identified by '123456';
use mysql;
update user set host='%' where user='root';
Navicat远程连接过程中,如果出现Authentication plugin 'caching_sha2_password' cannot be loaded
,是由于验证方式发生改变,
ALTER USER 'root'@'%' IDENTIFIED WITH mysql_native_password BY '123456';
修改后即可以连接。