设为首页 收藏本站
查看: 1394|回复: 0

[经验分享] MySQL5.7.18 for Linux7.2 源码安装

[复制链接]

尚未签到

发表于 2018-10-9 10:51:39 | 显示全部楼层 |阅读模式
  源码安装MySQL比较麻烦,需要安装依赖包,然后进行编译,时间较长,建议安装二进制的MySQL,时间比较快;
  用到的软件包:
  mysql-5.7.18.tar.gz
  boost_1_59_0.tar.gz
  1、安装依赖包
  yum -y install gcc* gcc-c++ ncurses* ncurses-devel* cmake* bison* libgcrypt* perl*
  2、创建MySQL用户:
  [root@localhost ~]# mkdir -p /mysql/data
  [root@localhost ~]# mkdir -p /mysql/mysql5718
  [root@localhost ~]# chown -R mysql.mysql /mysql/
  3、调整系统参数
  [root@localhost ~]# vim /etc/security/limits.conf
  *    soft    nproc     65535
  *    hard    nproc     65535
  *    soft    nofile    65535
  *    hard    nofile    65535
  [root@localhost ~]# vi /etc/security/limits.d/20-nproc.conf
  *    soft    nproc     65535
  [root@localhost ~]#  vi /etc/profile
  ulimit -u 65535
  ulimit -n 65535
  4、下载并解压软件
  [root@localhost ~]# tar zxvf mysql-5.7.18.tar.gz -C /usr/src/
  [root@localhost ~]# tar zxvf boost_1_59_0.tar.gz -C /mysql/
  [root@localhost ~]# chown -R mysql.mysql /mysql/
  [root@localhost ~]# chmod -R 755  /mysql/
  [root@localhost ~]# chown -R mysql.mysql /usr/src/mysql-5.7.18/
  5、开始编译安装MySQL5.7.18
  [root@localhost ~]# su - mysql
  [mysql@localhost ~]$ cd /usr/src/mysql-5.7.18/
  [mysql@localhost mysql-5.7.18]$cmake . -DCMAKE_INSTALL_PREFIX=/mysql/mysql5718 \
  -DMYSQL_DATADIR=/mysql/data \
  -DDOWNLOAD_BOOST=1 \
  -DWITH_BOOST=/mysql/boost_1_59_0
  [mysql@localhost mysql-5.7.18]$ make -j 4    (并行4个进程同时进行编译)
  [mysql@localhost mysql-5.7.18]$ make  install
  6、初始化数据库:
  [mysql@localhost ~]$ /mysql/mysql5718/bin/mysqld --initialize --user=mysql --basedir=/mysql/mysql5718/ --datadir=/mysql/data/
  ---注意,在初始化数据库会生成数据库的默认密码,这个密码要记住,一会登录数据库要用
  7、编辑my.cnf配置文件,启动数据库
  [mysql@localhost ~]$ vim my.cnf    (该配置文件仅供参考)
  [client]
  socket                    = /mysql/data/mysql.sock
  default_character_set     = utf8
  [mysql]
  socket=/mysql/data/mysql.sock
  [mysqld]
  server_id                 = 1607
  port                      = 3306
  basedir                   = /mysql/mysql5718/
  datadir                   = /mysql/data/
  socket                    = /mysql/data/mysql.sock
  pid_file                  = /mysql/data/mysql.pid
  log_error                 = /mysql/data/mysql_error.log
  log_bin                   = /mysql/data/mysql_bin
  relay_log                 = /mysql/data/relay_bin
  character_set_server      = utf8
  collation_server          = utf8_general_ci
  innodb_buffer_pool_size   = 8G
  innodb_buffer_pool_instances = 8
  innodb_log_file_size      = 1G
  innodb_log_files_in_group = 3
  innodb_log_buffer_size    = 24M
  innodb_flush_log_at_trx_commit = 1
  innodb_file_per_table     = 1
  innodb_flush_method       = O_DIRECT
  innodb_io_capacity        = 200
  innodb_io_capacity_max    = 600
  innodb_thread_concurrency = 0
  innodb_autoinc_lock_mode  = 2
  innodb_lock_wait_timeout  = 60
  innodb_read_io_threads    = 4
  innodb_write_io_threads   = 4
  innodb_max_dirty_pages_pct = 80
  innodb_autoextend_increment = 512
  innodb_checksum_algorithm = NONE
  innodb_doublewrite        = 0
  innodb_use_native_aio     = 1
  innodb_open_files         = 8192
  sync_binlog               = 1
  sync_relay_log            = 1
  relay_log_info_repository = TABLE
  master_info_repository    = TABLE
  expire_logs_days          = 10
  binlog_format             = ROW
  transaction-isolation     = READ-COMMITTED
  concurrent_insert         = 2
  skip_slave_start          = TRUE
  back_log                  = 2000
  thread_stack              = 256k
  thread_cache_size         = 256
  key_buffer_size           = 256M
  tmp_table_size            = 64M
  read_buffer_size          = 2M
  read_rnd_buffer_size      = 8M
  sort_buffer_size          = 2M
  join_buffer_size          = 2M
  query_cache_size          = 0
  query_cache_type          = 0
  max_heap_table_size       = 64M
  binlog_cache_size         = 2M
  table_open_cache          = 8192
  max_allowed_packet        = 64M
  bulk_insert_buffer_size   = 64M
  max_connect_errors        = 100000
  max_connections           = 500
  connect_timeout           = 300
  wait_timeout              = 86400
  interactive_timeout       = 86400
  lower_case_table_names    = 1
  open_files_limit          = 20480
  skip_name_resolve
  skip_external_locking
  explicit_defaults_for_timestamp = TRUE
  sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
  [mysql@localhost ~]$  /mysql/mysql5718/bin/mysqld_safe --defaults-file=/mysql/data/my.cnf  --user=mysql &
  8、进入数据库检查:
  [mysql@localhost ~]$  /mysql/mysql5718/bin/mysql -u root -p --socket=/mysql/data/mysql.sock
  Enter password:
  Welcome to the MySQL monitor.  Commands end with ; or \g.

  Your MySQL connection>  Server version: 5.7.18-log MySQL Community Server (GPL)
  Copyright (c) 2000, 2017, 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> set password='123456';  (因为刚才使用的密码是个默认的登录密码,所以我们要修改)
  mysql>  flush privileges;
  然后重新登录数据库,进行检查:
  [mysql@localhost ~]$  /mysql/mysql5718/bin/mysql -u root -p --socket=/mysql/data/mysql.sock
  Enter password:
  Welcome to the MySQL monitor.  Commands end with ; or \g.
  Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
  mysql> \s
  --------------
  /mysql/mysql5718/bin/mysql  Ver 14.14 Distrib 5.7.18, for linux-glibc2.5 (x86_64) using  EditLine wrapper

  Connection>  Current database:
  Current user:           root@localhost
  SSL:                    Not in use
  Current pager:          stdout
  Using outfile:          ''
  Using delimiter:        ;
  Server version:         5.7.18-log MySQL Community Server (GPL)
  Protocol version:       10
  Connection:             Localhost via UNIX socket
  Server characterset:    utf8
  Db     characterset:    utf8
  Client characterset:    utf8
  Conn.  characterset:    utf8
  UNIX socket:            /mysql/data/mysql.sock
  Uptime:                 25 min 16 sec
  Threads: 1  Questions: 19  Slow queries: 0  Opens: 110  Flush tables: 1  Open tables: 103  Queries per second avg: 0.012
  --------------
  mysql>


运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-619500-1-1.html 上篇帖子: mysql 备份脚本(xtrabackup) 下篇帖子: MySQL之SQL基础
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表