CentOS 8 安装mysql8 流程

去官网找到自己要安装的mysql版本,网址:https://dev.mysql.com/downloads/mysql/

找到对应版本,复制下载链接

然后用wget进行安装:

mkdir mysql
cd mysql
wget https://dev.mysql.com/get/Downloads/MySQL-8.0/mysql-8.0.22-1.el8.x86_64.rpm-bundle.tar

下载完成后,使用tar命令进行解压,解压出来是散的,所以需要提前新建一个文件夹

tar -xvf mysql-8.0.22-1.el8.x86_64.rpm-bundle.tar

安装步骤,以下需要按顺序进行安装

# 安装依赖
yum install libaio net-tools perl
yum install perl-JSON.noarch -y

# 按顺序安装mysql的各个组件(需要按顺序安装,否则会安装失败)
rpm -ivh mysql-community-common-8.0.22-1.el8.x86_64.rpm
rpm -ivh mysql-community-devel-8.0.22-1.el8.x86_64.rpm
rpm -ivh mysql-community-debuginfo-8.0.22-1.el8.x86_64.rpm
rpm -ivh mysql-community-debugsource-8.0.22-1.el8.x86_64.rpm
rpm -ivh mysql-community-libs-debuginfo-8.0.22-1.el8.x86_64.rpm
rpm -ivh mysql-community-server-debug-debuginfo-8.0.22-1.el8.x86_64.rpm
rpm -ivh mysql-community-server-debuginfo-8.0.22-1.el8.x86_64.rpm
rpm -ivh mysql-community-client-debuginfo-8.0.22-1.el8.x86_64.rpm
rpm -ivh mysql-community-client-plugins-8.0.22-1.el8.x86_64.rpm
rpm -ivh mysql-community-client-plugins-debuginfo-8.0.22-1.el8.x86_64.rpm
rpm -ivh mysql-community-test-debuginfo-8.0.22-1.el8.x86_64.rpm
rpm -ivh mysql-community-libs-8.0.22-1.el8.x86_64.rpm
rpm -ivh mysql-community-client-8.0.22-1.el8.x86_64.rpm
rpm -ivh mysql-community-server-8.0.22-1.el8.x86_64.rpm
rpm -ivh mysql-community-server-debug-8.0.22-1.el8.x86_64.rpm
rpm -ivh mysql-community-test-8.0.22-1.el8.x86_64.rpm

如果出现错误可以根据日志内容来判断,如:

https://blog.csdn.net/aiyowei1106/article/details/88703746

如果没有启动使用cat来查看日志

cat /var/log/mysqld/log

开启mysql服务

service mysqld start

查看服务是否启动

service mysqld status

停止mysql服务

service mysqld stop

正常启动的情况显示这样

查看mysql初始密码:

grep 'temporary password' /var/log/mysqld.log

初始密码是最后面那个YZxd-*)q720J

进入mysql

mysql -u root -p
YZxd-*)q720J

修改密码

set password for 'root'@'localhost' = password('root123');

以下是开启远程连接的步骤

设置mysql用户的加密方式为mysql_native_password

ALTER USER 'root'@'%' IDENTIFIED WITH mysql_native_password BY 'Mysql_888';

将mysql设置为任何ip都可以访问,不建议使用root用户来作为访问的用户,可以新建一个用户来作为远程访问用户

GRANT ALL PRIVILEGES ON *.* TO 'root'@'%';

刷新权限

flush privileges;

打开防火墙

service firewalld start

开放端口

firewall-cmd --zone=public --add-port=3307/tcp --permanent

重载防火墙,让修改生效

firewall-cmd --reload

现在就可以正常使用了...

posted @ 2021-01-09 20:56  信仰在心中  阅读(419)  评论(0编辑  收藏  举报