环境说明
环境说明:Linux为腾讯云的CentOS7.6
前期准备工作
- 查看Linux版本信息
cat /etc/redhat-release
uname -a
- 查看是否安装了mariadb(很多都默认安装了)
rpm -qa|grep mariadb
sudo rpm -e mariadb-libs-5.5.68-1.el7.x86_64
sudo rpm -e mariadb-libs-5.5.68-1.el7.x86_64
有多个则卸载多个
-
下载MySQL资源 官网传送门  -
将MySQL资源上传到服务器的software中  -
创建mysql文件夹及将MySQL资源拷贝到该目录下
cd /usr/local
mkdir mysql
cp /data/softrware/mysql-8.0.26-1.el7.x86_64.rpm-bundle.tar /usr/local/mysql
安装MySQL8.0.26
- 解压
tar -xvf mysql-8.0.26-1.el7.x86_64.rpm-bundle.tar
- 安装
rpm -ivh mysql-community-client-8.0.26-1.el8.x86_64.rpm
rpm -ivh mysql-community-client-plugins-8.0.26-1.el8.x86_64.rpm
rpm -ivh mysql-community-libs-8.0.26-1.el8.x86_64.rpm
rpm -ivh mysql-community-common-8.0.26-1.el8.x86_64.rpm
rpm -ivh mysql-community-server-8.0.26-1.el8.x86_64.rpm
- 查看MySQL状态
systemctl status mysqld
systemctl is-active mysqld
systemctl start mysqld
systemctl stop mysqld
netstat -lntup|grep 3306
lsof -i:3306
服务未启动 服务启动
- 查看密码
grep password /var/log/mysql.log
我这里第一次执行上面的命令时报错了,后面执行了一些查看的命令就能查看到密码了 注意:密码为圈起来:后面的内容
- 登录mysql
mysql -u root -p
输入上面查询到的密码,输入时不会显示出密码的,和没输入一样;看到下面的界面就说明登录进mysql了 
执行命令发现并不能查询默认的几个数据库,这里需要进行重置密码 6. 修改密码 第一次操作是需要进行修改密码的,登录进mysql后执行
alter user root@localhost identified by '#XIAOma123';
 这时候再进行查询,就可以看见默认的四个数据库啦 注意:我这里重置密码后重启了一下Mysql才看到默认的数据库
远程连接
这时候进行远程连接是连接不上的,因为默认的是仅localhost访问,需要修该root的访问权限
mysql -u root -p
use mysql;
update user set host = "%" where user = "root";
selete host,user from user;
flush privileges;
exit;
远程连接数据库  至此MySQL8.0.26安装及远程连接完毕;
|