centos 6.5_64bit最小化安装环境下源码安装mysql-5.6

    一、操作环境

    华为云服务 Centos 6.5_64bit最小化安装内网IP:10.124.156.237

    mysql-5.6.20.tar.gz

      二、源码编译安装流程

      1.基础环境搭建

      由于操作系统是最小化安装,因此一些常用的编译环境是没有安装的;加上我们的操作环境是内网,所以不能使用yum源。解决这个问题,可以从华为云购买一个临时公网Ip与我们服务器的内网IP进行邦定,这样我们就可以使用yum源来安装必要的编译环境了。

      yum -y install gccgcc-c++ vim tree make cmake autoconf openssl openssl-devel openssl-clients curlcurl-devel wget rsync expect readline readline-devel bison bison-devel  pcre pcre-devel zlib-devel zlib  freetype freetype-devel

      • 上面这段代码可以满足基本的环境操作,不仅仅适用于在安装mysql的过程中。

      2.mysql用户以及必需目录

      在mysql运行中涉及到很多权限的问题,所以提前进行这方面的准备,避免在后期遇到一些不必要的权限问题。

      groupadd mysql

      useradd -g mysql mysql

      mkdir -p/home/mysql/data/data_3306/binlog /home/mysql/data/data_3306/relay_log/home/mysql/data/data_3306/socket

      mkdir -p/home/mysql/data/data_3307/binlog /home/mysql/data/data_3307/relay_log/home/mysql/data/data_3307/socket

      chown –Rmysql.mysql  /home/mysql/

      3.     源码编译安装

      cd /usr/local/src/

      tar xf mysql-5.6.20.tar.gz

      cd mysql-5.6.20

      cmake .-DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_DATADIR=/home/mysql/data-DSYSCONFDIR=/etc -DWITH_MYISAM_STORAGE_ENGINE=1-DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_MEMORY_STORAGE_ENGINE=1-DWITH_READLINE=1 -DMYSQL_UNIX_ADDR=/var/lib/mysql/mysql.sock-DMYSQL_TCP_PORT=3306 -DENABLED_LOCAL_INFILE=1-DWITH_PARTITION_STORAGE_ENGINE=1 -DEXTRA_CHARSETS=all -DDEFAULT_CHARSET=utf8-DDEFAULT_COLLATION=utf8_general_ci

      make && makeinstall

      4.     初始化设置

      1)单实例初始化

      /usr/local/mysql/scripts/mysql_install_db--basedir=/usr/local/mysql --datadir=/home/mysql/data --user=mysql

      2)多实例初始化

      首先修改配置文件

      vim /etc/my.cnf

      [mysqld_multi]

      mysqld =/usr/local/mysql/bin/mysqld_safe

      mysqladmin =/usr/local/mysql/bin/mysqladmin

      #log = /home/mysql/data/log/mysqld_multi.log

      #user = root

      #password = password

      [mysqld1]

      socket =/home/mysql/data/data_3306/socket/mysql.sock

      port = 3306

      pid-file =/home/mysql/data/data_3306/3306.pid

      datadir =/home/mysql/data/data_3306

      user = mysql

      skip-name-resolve

      lower_case_table_names=1

      innodb_file_per_table=1

      back_log = 50

      max_connections = 300

      max_connect_errors =1000

      table_open_cache =2048

      max_allowed_packet =16M

      binlog_cache_size = 2M

      max_heap_table_size =64M

      sort_buffer_size = 2M

      join_buffer_size = 2M

      thread_cache_size = 64

      thread_concurrency = 8

      query_cache_size = 64M

      query_cache_limit = 2M

      ft_min_word_len = 4

      default-storage-engine= MYISAM

      thread_stack = 192K

      transaction_isolation= REPEATABLE-READ

      tmp_table_size = 64M

      log-bin=mysql-bin

      binlog_format=mixed

      slow_query_log

      long_query_time = 1

      server-id = 1

      key_buffer_size = 8M

      read_buffer_size = 2M

      read_rnd_buffer_size =2M

      bulk_insert_buffer_size= 64M

      myisam_sort_buffer_size= 128M

      myisam_max_sort_file_size= 10G

      myisam_repair_threads= 1

      myisam_recover

      innodb_additional_mem_pool_size= 16M

      innodb_buffer_pool_size= 200M

      innodb_data_file_path= ibdata1:10M:autoextend

      innodb_file_io_threads= 8

      innodb_thread_concurrency= 16

      innodb_flush_log_at_trx_commit= 1

      innodb_log_buffer_size= 16M

      innodb_log_file_size =512M

      innodb_log_files_in_group= 3

      innodb_max_dirty_pages_pct= 60

      innodb_lock_wait_timeout= 120

      [mysqld2]

      socket =/home/mysql/data/data_3307/socket/mysql.sock

      port = 3307

      pid-file =/home/mysql/data/data_3307/3307.pid

      datadir = /home/mysql/data/data_3307

      user = mysql

      skip-name-resolve

      lower_case_table_names=1

      innodb_file_per_table=1

      back_log = 50

      max_connections = 300

      max_connect_errors =1000

      table_open_cache =2048

      max_allowed_packet =16M

      binlog_cache_size = 2M

      max_heap_table_size =64M

      sort_buffer_size = 2M

      join_buffer_size = 2M

      thread_cache_size = 64

      thread_concurrency = 8

      query_cache_size = 64M

      query_cache_limit = 2M

      ft_min_word_len = 4

      default-storage-engine= MYISAM

      thread_stack = 192K

      transaction_isolation= REPEATABLE-READ

      tmp_table_size = 64M

      log-bin=mysql-bin

      binlog_format=mixed

      slow_query_log

      long_query_time = 1

      server-id = 1

      key_buffer_size = 8M

      read_buffer_size = 2M

      read_rnd_buffer_size =2M

      bulk_insert_buffer_size= 64M

      myisam_sort_buffer_size= 128M

      myisam_max_sort_file_size= 10G

      myisam_repair_threads= 1

      myisam_recover

      innodb_additional_mem_pool_size= 16M

      innodb_buffer_pool_size= 200M

      innodb_data_file_path= ibdata1:10M:autoextend

      innodb_file_io_threads= 8

      innodb_thread_concurrency= 16

      innodb_flush_log_at_trx_commit= 1

      innodb_log_buffer_size= 16M

      innodb_log_file_size =512M

      innodb_log_files_in_group= 3

      innodb_max_dirty_pages_pct= 60

      innodb_lock_wait_timeout= 120

      [mysqldump]

      quick

      max_allowed_packet =256M

      [mysql]

      no-auto-rehash

      [myisamchk]

      key_buffer_size = 512M

      sort_buffer_size =512M

      read_buffer = 8M

      write_buffer = 8M

      [mysqlhotcopy]

      interactive-timeout

      [mysqld_safe]

      open-files-limit =8192

      其次进行初始化操作:

      scripts/mysql_install_db--basedir=/usr/local/mysql --datadir=/home/mysql/data/data_3306 --user=mysql

      scripts/mysql_install_db--basedir=/usr/local/mysql --datadir=/home/mysql/data/data_3307 --user=mysql

      5.     修改环境变量

      这一步至关重要,因为涉及到启动时会报找不到my_print_defaults命令的错误,同时也为了以后方便操作。

      vim /etc/profile

      在末行添加exportPATH=$PATH:/usr/sbin/:/usr/local/mysql/bin

      保存退出执行:source /etc/profile

      6.     Mysql数据库的启动和关闭

      /usr/local/mysql/bin/mysqld_multi start 1,2  –>  mysqld_multi start 1,2

      mysqld_multi stop 1

      mysqld_multi stop 2

      7.     数据库的连接

      1)本地连接:

      mysql -S/home/mysql/data/data_3306/socket/mysql.sock #第一个实例连接

      mysql -S /home/mysql/data/data_3307/socket/mysql.sock  #第二个实例连接

      2)远程连接:

      mysql –h 10.124.156.237 –P 3306 –u root –p123  #指定端口号连接

      mysql –h 10.124.156.237 –P 3307 –u root –p123

      三、单机多实例作为多机‘从’设置

      四、报错总结

      1.启动报错

      WARNING: my_print_defaults command not found.

      Please make sure you have this command available and

      in your path. The command is available from the latest

      MySQL distribution.

      ABORT: Can‘t find command ‘my_print_defaults‘.

      This command is available from the latest MySQL

      distribution. Please make sure you have the command

      in your PATH.

      问题解析:找不到my_print_defaults命令,没有设置环境变量的缘故

      问题解决:cp /usr/local/mysql/bin/my_print_defaults/usr/bin/

      cp/usr/local/mysql/bin/mysqld_multi /usr/bin/

      2.     初始化报错

      FATAL ERROR: The parentdirectory for the data directory ‘/home/data/data_3306‘ does not exis

      If that path was really intended, please create that directory path andthen

      restart this script.

      If some other path was intended, please use the correct path whenrestarting this script.

      问题解析:文件目录不存在。没有执行编译安装中的第2步,或者配置文件my.cnf中填写有误

      问题解决:环境变量的配置

      vim /etc/profile

      在末行添加exportPATH=$PATH:/usr/sbin/:/usr/local/mysql/bin

      保存退出执行:source /etc/profile

      检查配置文件my.cnf

       

      时间: 2024-12-20 02:20:53

      centos 6.5_64bit最小化安装环境下源码安装mysql-5.6的相关文章

      CentOS 7下源码安装MySQL 5.7

      网上说linux安装mysql服务分两种安装方法: ①源码安装,优点是安装包比较小,只有几十M左右,缺点是安装依赖的库多,安装编译时间长,安装步骤复杂容易出错: ②使用官方编译好的二进制文件安装,优点是安装速度快,安装步骤简单,缺点是安装包很大,300M左右(5.7版本的是600M左右), 对于第二种方法,我搞了一天,无果,到某个环节实在是无法走通,老大那边也不让搞了,隔了几天老大又吩咐我在生产服务器上安装mysql,这次我就按照第一种方法源码安装方式 下载源码安装包 http://dev.my

      centos6.5下源码安装mysql密码修改

      Centos下源码安装mysql密码破解方法: 方法一:首先停止mysql服务,: /etc/init.d/mysqldstop 停止mysql ps -ef |grep mysql 查看mysql是否关闭 然后以跳过权限方式后台启动 /usr/local/mysql/bin/mysqld_safe--skip-grant-tables --user=mysql & /usr/local/mysql/bin/mysql进入mysql 或者执行mysql回车进入mysql,然后修改密码. 修改My

      CentOS7 下源码安装MySQL 8.0.11

      CentOS7 下源码安装MySQL 8.0.11 系统环境:CentOS7, 内核:Linux 3.10.0-862.el7.x86_64 如果有旧版本的MySQL,先卸载,用下面命令来查询出系统有哪些相关的MySQL包. rpm -qa | grep mysql 如果上述命令查询出有相关的MySQL包,就卸载 rpm -e 包名 卸载MariaDB包 yum remove mariadb-libs.x86_64 从MySQL官网下载源码包,并将该文件拷贝到系统中. https://dev.m

      Linux平台下源码安装mysql多实例数据库

      Linux平台下源码安装mysql多实例数据库[[email protected] ~]# netstat -tlunp | grep 330tcp6 0 0 :::3306 :::* LISTEN 6191/mysqld [[email protected] ~]# ss -tlunp | grep 330tcp LISTEN 0 80 :::3306 :::* users:(("mysqld",pid=6191,fd=10)) [[email protected] ~]# syst

      CentOS7下源码安装MySQL 8.x

      会选择使用源码安装MySQL,想必对MySQL及其他的安装方式已经有了一定的了解,这里就不对周边信息进行过多赘述了,直接开始吧. 编译MySQL比较消耗内存,如果机器内存较小,可能会在编译期间出现内存不足的异常.若没有设置swap分区的可以设置swap分区来解决,否则只能扩容内存了: [[email protected] ~]# dd if=/dev/zero of=/swapfile bs=1k count=2048000 [[email protected] ~]# mkswap /swap

      CentOS 6.5下源码安装MySQL 5.6

      mysql分为开发版本和稳定版本(GA),开发版本拥有最新的特性,但是并不稳定,也没有完全经过测试,可能存在严重的bug,而稳定版本是经过了长时间的测试,消除了具有已知的bug,其稳定性和安全性都得到一定的保障. 对于一个mysql的版本号如:mysql-5.6.1-m1,这个版本号意味着什么呢?1.对于5.6.1的解释:第一个数字5代表了文件格式,第二个数字6代表了发行级别,第三个数字1代表了版本号.更新幅度较小时,最后的数字会增加,出现了重大特性更新时,第二个数字会增加,文件格式改变时,第一

      Linux下源码安装MySQL 5.6(经典)

      一.安装前准备 1.安装make编译器 make编译器下载地址:http://www.gnu.org/software/make/ (系统默认自带)查看自己的系统是否安装某个软件,如果已经有了,就不用在安装了,但是也有可能之前被卸载           了. 如果你之前是使用rpm -ivh make装的,用 # rpm -qa | grep make肯定是能够找到的. 如果你是用 make && make install装的.那么最好直接去找执行程序,就知道有没装上去 # find /

      CentOS 6.5下源码安装LAMP(Linux+Apache+Mysql+Php)环境

      CentOS 6.5下源码安装LAMP(Linux+Apache+Mysql+Php)环境一. 系统环境:Linux系统版本: CentOS release 6.5Apache版本: httpd-2.2.24PHP 版本: php-5.6.11 二.安装前准备: 1.查看是否安装GCC ,GCC-C++编译器,如果没有则进行安装: 查看是否安装的命令: #gcc –v 若未安装在服务器联网情况下可以使用下列命令安装: #yum install gcc #yum install gcc-c++2.

      CentOS 7.4下源码安装 Apache HTTP Server(httpd-2.4.35)

      CentOS 7.4下源码安装 Apache HTTP Server(httpd-2.4.35) 前提:确保安装了expat-devel, APR包 (apr-1.6.3.tar.gz 和 apr-util-1.6.1.tar.gz); 用YUM方式安装expat-devel 和 apr-util-devel yum -y install expat-devel yum -y install apr-util-devel 解压apr-1.6.3.tar.gz后进入该目录下,执行: ./confi