一、离线安装包 文件准备

  这里以mysql-5.6.23-linux-glibc2.5-x86_64.tar.gz为例,记一次MySQL 5.6.x 的生产环境离线部署过程。使用SecureCRT连接生产部署的机器,这里注意使用root用户进行操作。

  mysql-5.6.23-linux-glibc2.5-x86_64.tar.gz文件,已放到网盘(为什么不放到仓库的原因:****,习惯了 ),

    链接:https://pan.baidu.com/s/1aOC4jUiVa5KcLS7dQwyCbA          提取码:kvuo

 

 

 

  1、检查是否安装过mysqld

[root@slave054 local]# ps -ef|grep mysqld
root       2428   2282  0 20:25 pts/0    00:00:00 grep --color=auto mysqld

[root@slave054 local]# rpm
-qa |grep -i mysql
[root@slave054 local]# ps
-ef|grep mysqld root 2432 2282 0 20:25 pts/0 00:00:00 grep --color=auto mysqld

 

  2、切换到/usr/local目录下

[root@slave054 ~]#  cd /usr/local
[root@slave054 local]# pwd
/usr/local
[root@slave054 local]# 

 

  3、使用rz 上传mysql-5.6.23-linux-glibc2.5-x86_64.tar.gz压缩文件

[root@slave054 local]# ll
total 0
drwxr-xr-x. 2 root root  6 Apr 11  2018 bin
drwxr-xr-x. 2 root root  6 Apr 11  2018 etc
drwxr-xr-x. 2 root root  6 Apr 11  2018 games
drwxr-xr-x. 2 root root  6 Apr 11  2018 include
drwxr-xr-x. 2 root root  6 Apr 11  2018 lib
drwxr-xr-x. 2 root root  6 Apr 11  2018 lib64
drwxr-xr-x. 2 root root  6 Apr 11  2018 libexec
drwxr-xr-x. 2 root root  6 Apr 11  2018 sbin
drwxr-xr-x. 5 root root 49 Nov 24 00:00 share
drwxr-xr-x. 2 root root  6 Apr 11  2018 src
[root@slave054 local]# rz
rz waiting to receive.
 zmodem trl+C ȡ

  100%  304464 KB 2495 KB/s 00:02:02       0 Errorssc2.5-x86_64.tar.gz...

[root@slave054 local]#

[root@slave054 local]# ll total
304468 drwxr-xr-x. 2 root root 6 Apr 11 2018 bin drwxr-xr-x. 2 root root 6 Apr 11 2018 etc drwxr-xr-x. 2 root root 6 Apr 11 2018 games drwxr-xr-x. 2 root root 6 Apr 11 2018 include drwxr-xr-x. 2 root root 6 Apr 11 2018 lib drwxr-xr-x. 2 root root 6 Apr 11 2018 lib64 drwxr-xr-x. 2 root root 6 Apr 11 2018 libexec -rw-r--r--. 1 root root 311771412 Nov 23 19:48 mysql-5.6.23-linux-glibc2.5-x86_64.tar.gz drwxr-xr-x. 2 root root 6 Apr 11 2018 sbin drwxr-xr-x. 5 root root 49 Nov 24 00:00 share drwxr-xr-x. 2 root root 6 Apr 11 2018 src [root@slave054 local]#

 

  

二、解压文件并建立软连接

  1、解压mysql-5.6.23-linux-glibc2.5-x86_64.tar.gz

[root@slave054 local]#  tar xzvf mysql-5.6.23-linux-glibc2.5-x86_64.tar.gz

 

  2、建立软连接

[root@slave054 local]# ln -s  mysql-5.6.23-linux-glibc2.5-x86_64 mysql

[root@slave054 local]# ll total
304468 drwxr-xr-x. 2 root root 6 Apr 11 2018 bin drwxr-xr-x. 2 root root 6 Apr 11 2018 etc drwxr-xr-x. 2 root root 6 Apr 11 2018 games drwxr-xr-x. 2 root root 6 Apr 11 2018 include drwxr-xr-x. 2 root root 6 Apr 11 2018 lib drwxr-xr-x. 2 root root 6 Apr 11 2018 lib64 drwxr-xr-x. 2 root root 6 Apr 11 2018 libexec lrwxrwxrwx. 1 root root 34 Nov 25 20:32 mysql -> mysql-5.6.23-linux-glibc2.5-x86_64 drwxr-xr-x. 13 root root 213 Nov 25 20:31 mysql-5.6.23-linux-glibc2.5-x86_64 -rw-r--r--. 1 root root 311771412 Nov 23 19:48 mysql-5.6.23-linux-glibc2.5-x86_64.tar.gz drwxr-xr-x. 2 root root 6 Apr 11 2018 sbin drwxr-xr-x. 5 root root 49 Nov 24 00:00 share drwxr-xr-x. 2 root root 6 Apr 11 2018 src [root@slave054 local]#

 

 

三、用户和用户组

  1、添加dba用户组

[root@slave054 local]# groupadd -g 101 dba

 

  2、新建mysqladmin用户

[root@slave054 local]# useradd -u 514 -g dba -G root -d /usr/local/mysql mysqladmin
useradd: warning: the home directory already exists.
Not copying any file from skel directory into it.

[root@slave054 local]#  id mysqladmin
uid=514(mysqladmin) gid=101(dba) groups=101(dba),0(root)

[root@slave054 local]# passwd mysqladmin
Changing password for user mysqladmin.
New password: 
BAD PASSWORD: The password is shorter than 8 characters
Retype new password: 
passwd: all authentication tokens updated successfully.
[root@slave054 local]# 

 

  如果mysqladmin 已经存在,则执行如下命令:

usermod -u 514 -g dba -G root -d /usr/local/mysql mysqladmin

 

 

  3、复制环境变量配置文件至mysqladmin用户的home目录

[root@slave054 local]# cp /etc/skel/.* /usr/local/mysql 
cp: omitting directory ‘/etc/skel/.’
cp: omitting directory ‘/etc/skel/..’
cp: omitting directory ‘/etc/skel/.mozilla’
[root@slave054 local]# 

 

  4、my.cnf文件配置

[root@slave054 local]# cd /etc/
[root@slave054 etc]# vi my.cnf
[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
# 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=/var/log/mariadb/mariadb.log
pid-file=/var/run/mariadb/mariadb.pid

#
# include all files from the config directory
#
!includedir /etc/my.cnf.d

~
~
~
~
"my.cnf" 19L, 570C
my.cnf默认配置

相关文章:

  • 2022-12-23
  • 2021-08-01
  • 2021-04-20
  • 2021-12-06
  • 2021-05-15
  • 2021-08-02
  • 2021-07-23
猜你喜欢
  • 2021-07-21
  • 2021-07-22
  • 2022-12-23
  • 2022-02-25
  • 2022-03-09
  • 2021-10-10
  • 2021-09-24
相关资源
相似解决方案