MySQL8.0.26-Linux版安装
1.准备一台Linux服务器
云服务器或者虚拟机都可以;
Linux的版本为 Centos7;
2.下载Linux版MySQL安装包
https://downloads.mysql.com/archives/community
3.创建目录、解压
mkdir mysq1//创建目录
tar -xvf mysql安装包.x86 64.rpm-bundle.tar -C mysql//解压到mysql目录下
4.安装mysql安装包(rpm安装包不会处理依赖关系,所以需要按顺序安装)
cd mysql
rpm -ivh mysql-community-common-8.0.26-1.e17.x86_64.rpm
rpm -ivh mysql-community-client-plugins-8.0.26-1.e17.x86_64.rpm
rpm -ivh mysql-community-libs-8.0.26-1.e17.x86_64.rpm
rpm -ivh mysgl-community-libs-compat-8.0.26-1.e17.x86_64.rpm
yum install openssl-devel
rpm -ivh mysql-community-devel-8.0.26-1.e17.x86_64.rpm//会依赖openssl,需要执行yum install openssl-devel命令进行安装
rpm -ivh mysql-community-client-8.0.26-1.e17.x86_64.rpm
rpm -ivh mysql-community-server-8.0.26-1.el7.x86_64.rpm
5.启动MYSQL服务
systemctl start mysqld
systemctl restart mysqld
systemct1stop mysqld
6.查询自动生成的root用户密码
grep 'temporary password' /var/log/mysqld.log
7.登录和root用户密码
mysql -u root -p
ALTER USER 'root'@'localhost' IDENTIFIED BY '123456a?';
//设置密码长度
set global validate password.policy=4;
8.创建用户
默认的root用户只能当前节点1ocalhost访问,是无法远程访问的,我们还需要创建一个root账户,用户远程访问
create user 'root'@'%'IDENTIFIED WITH mysql_native_password BY '1234';
9.给用户分配权限
grant all on . to 'root'@'%':