当前位置:   article > 正文

Centos7安装Percona5.7

centos7编译安装percona-server5.7

OS: Centos7.0
DB: Percona5.7

1. 通过yum安装

  1. ## 删除之前的mysql数据库, 我用的是centos7.再安装虚拟机的时候,预装了很多软件。所以mysql和mariadb的一些东西安装了。必须要删除掉
  2. rpm -qa | grep mysql
  3. rpm -qa | grep mariadb
  4. rpm -e mysql
  5. rpm -e --nodeps mysql
  6. yum remove mariadb-libs-5.5.41-2.el7_0.x86_64
  7. ## 安装其他依赖包:perl 和libaio
  8. yum -y install perl-Module-Install.noarch
  9. yum -y install libaio libaio-devel
  10. ## 配置yum安装源
  11. yum install https://www.percona.com/redir/downloads/percona-release/redhat/0.1-4/percona-release-0.1-4.noarch.rpm ## 最新的是0.1-4
  12. ## 安装percona
  13. yum install Percona-Server-server-57

2. 通过rpm安装

  1. wget https://www.percona.com/downloads/Percona-Server-LATEST/Percona-Server-5.7.18-16/binary/redhat/7/x86_64/Percona-Server-5.7.18-16-rd7301f8-el7-x86_64-bundle.tar
  2. tar xvf Percona-Server-5.7.18-16-rd7301f8-el7-x86_64-bundle.tar
  3. rpm -ivh Percona-Server-shared-compat-57-5.7.18-16.1.el7.x86_64
  4. rpm -ivh Percona-Server-shared-57-5.7.18-16.1.el7.x86_64
  5. rpm -ivh Percona-Server-client-57-5.7.18-16.1.el7.x86_64
  6. rpm -ivh Percona-Server-server-57-5.7.18-16.1.el7.x86_64

3. 配置

  1. ## 配置用户组
  2. groupadd mysql
  3. useradd -r -g mysql mysql
  4. mysqld --initialize --user=mysql --datadir=/user/local/webserver/mysql ## 如果没报错,恭喜你很幸运

vim /etc/percona-server.conf.d/mysqld.cnf

  1. [mysqld]
  2. datadir=/usr/local/webserver/mysql
  3. socket=/usr/local/webserver/mysql/mysql.sock
  4. # initialize need
  5. explicit_defaults_for_timestamp=true
  6. # Disabling symbolic-links is recommended to prevent assorted security risks
  7. symbolic-links=0
  8. log-error=/var/log/mysqld.log
  9. pid-file=/var/run/mysqld/mysqld.pid
  10. [mysql]
  11. socket=/usr/local/webserver/mysql/mysql.sock

chown -R mysql:mysql /usr/local/webserver/mysql

service mysqld start ## 如果没报错,恭喜你很幸运。

4. 登录

  1. cat /var/log/mysqld.log | grep "temporary password" ## 找到root的初始密码。
  2. mysql -u root -p
  3. set password = password('root');

5. ERROR

  • mysqld --initialize 报错:TIMESTAMP with implicit DEFAULT value is deprecated

    从 5.6开始,timestamp 的默认行为已经是 deprecated

  1. vim /etc/percona-server.conf.d/mysqld.cnf
  2. explicit_defaults_for_timestamp=true ## 加上这段(显示指定默认值为timestamp类型的字段)
  • mysql --initialize 报错:initialize specified but the data directory has files in it. Aborting.

    datadir 已经存在了。删除即可

  • service mysqld start 报错:InnoDB: .\ibdata1 must be writable > InnoDB 在启动时需要配置LOG File的目录,如果没有制定目录,则会在MySQL Data目录下创建2个日志文件ib_logfile0 and ib_logfile1,在创建的时候需要确保MYSQL拥有对该目录的权限。

  1. ps -ef | grep mysqld
  2. kill 21222 ## kill掉mysqld的进程
  3. rm /usr/local/webserver/mysql/ib_logfil*
  4. service mysqld start
  • service mysqld start 报错:Could not create unix socket lock file /user/lib/mysql/mysql.sock.lock.
  1. ## 很简单的问题。加权限即可
  2. chown -R mysql:mysql /user/lib/mysql/

6. 总结

安装mysql的数据库必要步骤有:

  1. 安装依赖包
  2. 安装mysql数据库
  3. 初始化服务(mysqld --initialize)
  4. 修改配置文件,配置datadir目录权限和用户
  5. 启动服务,链接数据库

参考资料

  1. MySQL 5.6 中TIMESTAMP with implicit DEFAULT value is deprecated错误
  2. MYSQL 服务无法启动,错误日志:InnoDB: .\ibdata1 must be writable
  3. 如何在 CentOS 7 上安装 Percona服务器
  4. percona5.7 源码安装

<wiz_tmp_tag id="wiz-table-range-border" contenteditable="false" style="display: none;">

 
 
 
 

转载于:https://www.cnblogs.com/gelu/p/7458679.html

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/黑客灵魂/article/detail/877121
推荐阅读
相关标签
  

闽ICP备14008679号