离线部署MySQL5.6(无网环境)

离线部署MySQL5.6

一.部署依赖包

阿里云盘

1.卸载mariadb

[root@localhost ~]# rpm -qa|grep mariadb  // 查询出来已安装的mariadb
[root@localhost ~]# rpm -e --nodeps 文件名  // 卸载mariadb,文件名为上述命令查询出来的文件

2.安装依赖包

需要安装autoconf,m4,Data:Dumper(阿里云盘)

先安装M4,再安装Data:Dumper,再安装autoconf

[root@localhost ~]# tar -zxvf m4-1.4.18.tar.gz
[root@localhost ~]# cd m4-1.4.18
[root@localhost m4-1.4.18]# ./configure

Data:Dumper解压之后直接rpm -ivh 安装

[root@localhost ~]# rpm -ivh  .......       (解压之后的rpm)

autoconf:

[root@localhost ~]# tar -zxvf autoconf-2.69.tar.gz
[root@localhost ~]# cd autoconf-2.69
[root@localhost autoconf-2.69]# ./configure 

二.部署mysql

1.创建用户,用户组及目录

[root@localhost ~]# groupadd mysql
[root@localhost ~]# useradd -g mysql mysql 
[root@localhost ~]# mkdir /var/log/mysql
[root@localhost ~]# chown -R mysql:mysql /usr/local/mysql
[root@localhost ~]# chown -R mysql:mysql /var/log/mysql
[root@localhost ~]# chown -R mysql:mysql /var/log/mysql/mysql-slow

2.解压安装

[roort@localhost ~]# tar -xvf  mysql-5.6.51-linux-glibc2.12-x86_64.tar.gz   -C /usr/local
[roort@localhost ~]# mv  mysql-5.6.51-linux-glibc2.12

3.配置文件

[root@localhost ~]# cd /usr/local/mysql/support-files
[root@localhost support-files]# cp my-default.cnf /etc/my.cnf
[root@localhost support-files]# vim /etc/my.cnf
[mysql]
default-character-set=utf8
socket=/usr/local/mysql/mysql.sock
[mysqld] skip-name-resolve port = 3306 socket=/usr/local/mysql/mysql.sock basedir=/usr/local/mysql datadir=/usr/local/mysql/data max_connections=200 character-set-server=utf8 default-storage-engine=INNODB lower_case_table_names=1 max_allowed_packet=16M log-error=/var/log/mysql/mysql.log
slow_query_log=1
slow_query_log_file=/var/log/mysql/mysql-slow/
long_query_time=3 pid-file=/var/log/mysql/mysql.pid bind-address = 0.0.0.0
expire_logs_days=10

4.编译配置

[root@localhost ~]# cd /usr/local/mysql
[root@localhost mysql]# ./scripts/mysql_install_db --user=mysql --basedir=/usr/local/mysql/ --datadir=/usr/local/mysql/data/

5.配置环境变量

[root@localhost ~]# vim /etc/profile
export PATH
=$PATH:/usr/local/mysql/bin [root@localhost ~]# source /etc/profile

6.加入systemctl服务

    vim /usr/lib/systemd/system/mysql.service

    [Unit]
    Description=mysql
    After=network.target remote-fs.target nss-lookup.target
    [Service]
    Type=forking
    ExecStart=/usr/local/mysql/support-files/mysql.server start
    ExecReload=/usr/local/mysql/support-files/mysql.server restart
    ExecStop=/usr/local/mysql/support-files/mysql.server stop
    PrivateTmp=true
    [Install]
    WantedBy=multi-user.target

7.开启服务

[root@localhost ~]# systemctl start mysql
[root@localhost ~]# systemctl enable mysql

 

posted @ 2022-02-17 15:31  Noleaf  阅读(151)  评论(0编辑  收藏  举报