James 发表于 2018-10-1 09:34:54

centos7离线安装mysql5.6.34

  Centos7将默认数据库mysql替换成了Mariadb,安装没那么方便了。
  如果用yum还容易些,改改下载源,上网就可以安装。
  离线的话,先去下载一个安装包,我下载的是mysql-5.6.34-linux-glibc2.5-x86_64.tar.gz,
  http://ftp.ntu.edu.tw/MySQL/Downloads/MySQL-5.6/
  还可以下载到。
  安装的时候需要用到perl-Data-Dumper.x86_64,不然会出错误提示
  FATAL ERROR: please install the following Perl modules before executing /usr/local/mysql/scripts/mysql_install_db:Data::Dumper
  可以自己下载,不大,45K就上传到这里,文章最下面有下载链接。
  http://search.cpan.org/~smueller/Data-Dumper-2.154/
  这里也有
  安装的centos7是64位,不要选默认的最小安装,不然perl的插件就没有,选基本网络就好,不过还是没有perl-Data-Dumper.x86_64。
  选基本网络模式安装,mariadb就自动进来了,需要删除掉。
  rpm -qa | grep mariadb
  看一下是不是有,如果有都删掉。
  rpm -e --nodeps 列表里面的项目
  上传从这里下载的perl-Data-Dumper并安装
  rpm -ivh perl-Data-Dumper-2.145-3.el7.x86_64.rpm
  新安装的机器应该没有/etc/my.cnf,不过保险起见,还是看看,有删了。
  建立组和用户
  groupadd mysql
  useradd -g mysql mysql
  把下载的安装包上传到/usr/local/
  展开
  tar -zxvf mysql-5.6.34-linux-glibc2.5-x86_64.tar.gz
  把展开的目录改成mysql
  mv mysql-5.6.34-linux-glibc2.5-x86_64 mysql
  自己产生一个、etc/my.cnf
  内容:
  
  default-character-set=utf8
  socket=/var/lib/mysql/mysql.sock
  
  skip-name-resolve
  port = 3306
  socket=/var/lib/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
  把mysql文件夹所有者修改为mysql用户和组
  cd /usr/local/mysql
  chown -R mysql:mysql ./  
  开始安装
  ./scripts/mysql_install_db --user=mysql
  在修改一下data目录的所有权
  chown -R mysql:mysql data
  制作启动连接
  cp ./support-files/mysql.server /etc/rc.d/init.d/mysqld
  加执行权
  chmod +x /etc/rc.d/init.d/mysqld
  做成自动服务
  chkconfig --add mysqld
  确认一下
  chkconfig --list mysqld
  启动
  service mysqld start
  查看状态
  service mysqld status
  SUCCESS! MySQL running (10832)
  编辑/etc/profile文件,加入环境变量,把这样一行加进入
  export PATH=$PATH:/usr/local/mysql/bin
  立刻生效
  . /etc/profile
  试一试
  mysql -u root
  Welcome to the MySQL monitor.Commands end with ; or \g.

  Your MySQL connection>  Server version: 5.6.34 MySQL Community Server (GPL)
  Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.
  Oracle is a registered trademark of Oracle Corporation and/or its
  affiliates. Other names may be trademarks of their respective
  owners.
  Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
  mysql>
  不要带-p,会提示要输入密码,输啥肯定是个死啊,还没配置呢,不过好像直接回车也行。
  下面修改密码
  mysql> use mysql
  mysql> update user set password=password('shen_xu123') where user='root' and host='localhost';
  Query OK, 1 row affected (0.00 sec)
  Rows matched: 1Changed: 1Warnings: 0
  让远程可以访问

  GRANT ALL PRIVILEGES ON *.* TO 'your username'@'%'>  'your username'和'your password'自行修改

页: [1]
查看完整版本: centos7离线安装mysql5.6.34