noel0217 发表于 2018-10-6 11:35:36

使用二进制包安装mysql-guo

目的
  本文主要讲述如何使用二进制安装mysql,并启动mysql

1、mysql安装包的下载
  

https://dev.mysql.com/downloads/mysql/  

2、安装mysql前的准备


[*]上传mysql安装包至/usr/local目录
[*]解压mysql安装包;  

# tar xvf mysql-5.6.39-linux-glibc2.12-x86_64.tar.gz
[*]将解压后的文件夹连接至mysql文件夹  

# ln -s mysql-5.6.39-linux-glibc2.12-x86_64 mysql
[*]检查并安装依赖包(perl)  

  
# yum -y install perl perl-devel perl-Data-Dumper

  

> 如若未安装perl组件将会报以下错误  

  

  # ./mysql_install_db
  FATAL ERROR: please install the following Perl modules before executing ./mysql_install_db:
  Data::Dumper
  

  
- 检查并安装依赖包(libaio)
  

  

  # yum list|grep libaio
  libaio.i686                              0.3.109-13.el7                base
  libaio.x86_64                            0.3.109-13.el7                base
  libaio-devel.i686                        0.3.109-13.el7                base
  libaio-devel.x86_64                      0.3.109-13.el7                base
  # yum -y install libaio libaio-devel
  

> 若如为安装libaio组件将会报以下错误  

  

  # scripts/mysql_install_db --user=mysql
  WARNING: The host 'Alinx' could not be looked up with ./bin/resolveip.
  This probably means that your libc libraries are not 100 % compatible
  with this binary MySQL version. The MySQL daemon, mysqld, should work
  normally with the exception that host name resolving will not work.
  This means that you should use IP addresses instead of hostnames
  when specifying MySQL privileges !
  Installing MySQL system tables..../bin/mysqld: error while loading shared libraries: libaio.so.1: cannot open shared object file: No such file or directory
  #
  

  
###3、创建mysql用户,用户组并将目录授权给mysql用户
  

  # groupadd mysql
  # useradd -r -g mysql mysql
  # chown mysql:mysql /usr/local/mysql -R
  # ll /usr/local/
  total 321180
  drwxr-xr-x.2 rootroot          6 Aug 122015 bin
  drwxr-xr-x.2 rootroot          6 Aug 122015 etc
  drwxr-xr-x.2 rootroot          6 Aug 122015 games
  drwxr-xr-x.2 rootroot          6 Aug 122015 include
  drwxr-xr-x.2 rootroot          6 Aug 122015 lib
  drwxr-xr-x.2 rootroot          6 Aug 122015 lib64
  drwxr-xr-x.2 rootroot          6 Aug 122015 libexec
  lrwxrwxrwx   1 mysql mysql      35 Jan 16 22:46 mysql -> mysql-5.6.39-linux-glibc2.12-x86_64
  drwxr-xr-x13 mysql mysql      4096 Jan 16 22:38 mysql-5.6.39-linux-glibc2.12-x86_64
  -rw-r--r--   1 rootroot328882304 Jan 212018 mysql-5.6.39-linux-glibc2.12-x86_64.tar.gz
  drwxr-xr-x.2 rootroot          6 Aug 122015 sbin
  drwxr-xr-x.5 rootroot         46 Jan 172017 share
  drwxr-xr-x.2 rootroot          6 Aug 122015 src
  

> 此时可以看到mysql目录的归属为mysql:mysql  
- 删除系统中的mysql配置文件
  

  rm -f /etc/my.cnf
  rm -fr /etc/my.cnf.d/
  

  
### 4、初始化并启动mysql
  
- 初始化
  

  # scripts/mysql_install_db --user=mysql --datadir=/usr/local/mysql/data --skip-name-resolve
  

> 该步骤为创建了一个root用户(空密码),并初始化了mysql的一些权限账户表  

  
- 拷贝配置文件以及启动脚本
  

  # cp support-files/my-default.cnf /etc/my.cnf
  # cp support-files/mysql.server /etc/init.d/mysqld
  

- 编辑/etc/my.cnf文件,并写入如下内容  

  basedir = /usr/local/mysql
  datadir = /usr/local/mysql/data/
  

  
### 5、启动mysql
  

  
- 启动mysql
  

  /usr/local/mysql/support-files/mysqld start
  

- 为mysql数据库设置密码(跟进提示进行密码设置,部署完时密码为空)  

  # ./bin/mysql_secure_installation
  

- 登录数据库  

  # mysql -uroot -pAlinx
  

  
> 当前启动时候报错(发现是/etc/my.cnf未配置目录导致)
  

  

  # /usr/local/mysql/support-files/mysql.server start
  Starting MySQL.Logging to '/usr/local/mysql/data/localhost.err'.
  ERROR! The server quit without updating PID file (/usr/local/mysql/data/localhost.pid).
  #
  



页: [1]
查看完整版本: 使用二进制包安装mysql-guo