离线安装mysql5.7,图文介绍

mysql版本5.7.26

下载

点击下载

image

image

选择版本号

image

选择机型,位数

image

上传到服务器

image

步骤:

卸载原有的mariadb

 rpm -qa | grep mariadb
 rpm -e --nodeps mariadb-libs-5.5.60-1.el7_5.x86_64

关闭selinux

打开/etc/sysconfig/selinux,把SELINUX=enforcing改为SELINUX=disabled

创建mysql 用户 以及用户组

groupadd mysql
创建mysql用户,并且以mysql创建文件
useradd -g mysql mysql -d /var/mysql

解压

tar -zxvf mysql-5.7.26-linux-glibc2.12-x86_64.tar.gz

建立软连接

方便升级

ln -s mysql-5.7.26-linux-glibc2.12-x86_64.tar.gz mysql

ll 查看结果

image

建立存储mysql数据的文件夹(记得给运行mysql用户写入权限)

chown mysql:mysql /opt/tools/mysql/data

配置/etc/my.cf (全局所有用户都会使用的配置)

image

本次配置的my.cnf

[client]
port=3306
socket=/tmp/mysql.sock
default-character-set=utf8mb4

[mysqld]

#skip-grant-tables
#开启binlog日志
#log-bin=mysql-bin
#expire_logs_days=7

port=3306
server-id=1
bind-address=0.0.0.0
datadir=/opt/tools/mysql/data
basedir=/opt/tools/mysql
#pid-file=/tmp/mysql/mysql.pid

character_set_server=utf8mb4
init_connect='SET NAMES utf8mb4'
#最大连接数
max_connections=400
#超过1800s 断开连接
interactive_timeout = 1800
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0
# Settings user and group are ignored when systemd is used.
# If you need to run mysqld under a different user or group,
# customize your systemd unit file for mariadb according to the
# instructions in http://fedoraproject.org/wiki/Systemd

[mysqld_safe]
log-error=/tmp/mysql/mysql.log
pid-file=/tmp/mysql/mysql.pid


#
# include all files from the config directory
#

对应的文件夹要建立对应的文件

mkdir /tmp/mysql
touch /tmp/mysql/mysql.log
touch /tmp/mysql/mysql.pid
chown mysql:mysql /tmp/mysql/mysql.log
chown mysql:mysql /tmp/mysql/mysql.pid

image

初始化mysqld

./mysqld --initialize --user=mysql

如果没有报错,则是成功,记录下来密码,登录mysql要用到

添加到service服务中

修改/opt/tools/mysql/share/mysql/mysql.server 和/etc/my.cnf配置一样.理论上配置my.cnf,就不需要配置,但是目前遇到过问题,所以就配置上

  1. datadir
  2. basedir
  3. pid-file

image

复制到init.d
cp /opt/tools/mysql/share/mysql/mysql.server /etc/init.d/mysqld


加入服务
chkconfig --add mysqld


启动
service mysqld start

启动mysqld

登录到mysql客户端

mysql  -u root -p

修改密码

ALTER USER 'root'@'localhost' IDENTIFIED BY '123456'

用新密码登录mysql

如果忘记密码

vim /etc/my.cnf

skip-grant-tables (跳过验证) 重启mysqld(service mysqld restart)

进入mysql 更新user表

use mysql;
update user set authentication_string=password('123456') where user="root";
flush privileges;

修改 /etc/my.cnf 注释验证,重启mysqld

新密码登录

报错


Starting MySQL. ERROR! The server quit without updating PID file (/opt/tools/mysql/data/node3.pid).

解决方案:

在/etc/my.cnf 中配置pid ,然后建立对应的文件.并赋予初始化mysql用户的写入的权限

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值