申明:本文乃“运维家”原创,转载请注明出处,更多内容请关注公众号“运维家”。
主旨
作为最常用的数据库,mysql的安装也是我们必须掌握的,接下来我们就演示下在linux之Centos7的服务器上如何进行安装最新版mysql的。
环境
linux服务器一台 # centos/redhat
mysql8.0.28软件包一个 # 其余版本类似
navicat 客户端工具
软件下载
可以从官网进行下载,但是不推荐,有时候官网找半天,还下载个错误的,这里给你直接准备好了,关注公众号 “运维家”,后台回复 “mysql8 ”即可获取下载地址。
安装前准备
[yunweijia@localhost?~]$?sudo?setenforce?0??#?管理selinux,这里是临时关闭,要永久关闭请查看我之前的文章
[yunweijia@localhost?~]$?sudo?systemctl?stop?firewalld.service??#?关闭防火墙
[yunweijia@localhost ~]$ sudo systemctl disable firewalld.service
Removed symlink /etc/systemd/system/multi-user.target.wants/firewalld.service.
Removed symlink /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.
[yunweijia@localhost?~]$?sudo?rpm?-qa?|?grep?mysql??#?检查之前时候有mysql安装的内容,如果有请使用rpm?-e命令进行卸载
[yunweijia@localhost ~]$ rpm -qa| grep mariadb
mariadb-libs-5.5.56-2.el7.x86_64
[yunweijia@localhost?~]$?sudo?rpm?-e?mariadb-libs-5.5.56-2.el7.x86_64?--nodeps
[yunweijia@localhost?~]$?sudo yum -y install libaio # mysql依赖
[yunweijia@localhost ~]$ sudo yum -y install perl # mysql依赖
[yunweijia@localhost?~]$?sudo?yum?-y?install?net-tools??# mysql依赖
PS:如果centos/redhat版本是8.0以上,还需要额外安装如下依赖:
[yunweijia@localhost?~]$?yum?-y?install?ncurses-compat-libs
软件上传
[yunweijia@localhost jier]$ ls
mysql-8.0.28-1.el7.x86_64.rpm-bundle.tar
[yunweijia@localhost jier]$ pwd
/home/yunweijia/jier
[yunweijia@localhost jier]$
安装
[yunweijia@localhost ~]$ cd /home/yunweijia/jier/
[yunweijia@localhost jier]$ tar xf mysql-8.0.28-1.el7.x86_64.rpm-bundle.tar
[yunweijia@localhost jier]$ sudo rpm -ivh mysql-community-common-8.0.28-1.el7.x86_64.rpm
[yunweijia@localhost jier]$ sudo rpm -ivh mysql-community-client-plugins-8.0.28-1.el7.x86_64.rpm
[yunweijia@localhost jier]$ sudo rpm -ivh mysql-community-libs-8.0.28-1.el7.x86_64.rpm
[yunweijia@localhost jier]$ sudo rpm -ivh mysql-community-client-8.0.28-1.el7.x86_64.rpm
[yunweijia@localhost jier]$ sudo rpm -ivh mysql-community-icu-data-files-8.0.28-1.el7.x86_64.rpm
[yunweijia@localhost jier]$ sudo rpm -ivh mysql-community-server-8.0.28-1.el7.x86_64.rpm
启动
[yunweijia@localhost jier]$ sudo systemctl status mysqld # 查看启动状态
[yunweijia@localhost?jier]$?sudo?systemctl?start?mysqld # 启动
修改密码
PS:第一次登录的时候必须修改安装时候的临时密码;
查找密码:
[yunweijia@localhost jier]$ sudo grep "temporary password" /var/log/mysqld.log
使用密码登录;
[yunweijia@localhost jier]$ mysql -uroot -p
修改密码
mysql>?alter?user?'root'@'localhost'?identified?by?'Yunweijia@123';??#?修改root密码为“Yunweijia@123”
Query OK, 0 rows affected (0.01 sec)
mysql> flush privileges; # 刷新配置
Query OK, 0 rows affected (0.00 sec)
mysql>
配置远程登录用户
mysql> create user yunweijia@'%' identified by 'Yunweijia@123'; # 新建用户yunweijia
Query OK, 0 rows affected (0.01 sec)
mysql> grant all privileges on *.* to yunweijia@'%' with grant option; # 给新建用户进行授权
Query OK, 0 rows affected (0.00 sec)
mysql> flush privileges; # 刷新权限
Query OK, 0 rows affected (0.00 sec)
mysql>
客户端登录验证
至此,搭建mysql8最新版完毕。
|