ubuntu / Installing MySQL 5.6.x from source

  • root user
sudo -i
  • preconfiguration setup
apt-get install -y cmake build-essential libreadline6-dev libncurses5-dev
groupadd mysql
useradd -r -g mysql mysql
mkdir -p /data/mysql
wget http://cdn.mysql.com/Downloads/MySQL-5.6/mysql-5.6.10.tar.gz
tar xvfz mysql-5.6.10.tar.gz
cd mysql-5.6*
rm CMakeCache.txt
cmake -DCMAKE_INSTALL_PREFIX=/data/mysql \
-DMYSQL_DATADIR=/data/mysqldb \
-DSYSCONFDIR=/etc/mysql \
-DMYSQL_UNIX_ADDR=/data/mysql/mysql.sock \
-DWITH_MYISAM_STORAGE_ENGINE=1 \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DWITH_MEMORY_STORAGE_ENGINE=1 \
-DWITH_READLINE=1 \
-DENABLED_LOCAL_INFILE=1 \
-DWITH_PARTITION_STORAGE_ENGINE=1 \
-DEXTRA_CHARSETS=all \
-DDEFAULT_CHARSET=utf8 \
-DDEFAULT_COLLATION=utf8_general_ci \
-DWITH_EXTRA_CHARSETS:STRING=utf8,gbk
.
make
make install

  • postinstallation setup
chown -R root .
chgrp -R mysql .
chown -R mysql data
chown -R mysql:mysql * (目录包括 /data/mysql /data/mysqld /var/run/mysqld/)目录属性不对mysqld也启动不起来,提示无权限./scripts/mysql_install_db --user=mysql --basedir=/data/mysql --datadir=/data/mysqldb --defaults-file=/etc/mysql/my.cnf
  • run
bin/mysqld_safe --user=mysql &
bin/mysqladmin -u root password 'new-password'

  • init.d shell
cp support-files/mysql.server /etc/init.d/mysql.server
ln -s /etc/init.d/mysql.server /etc/rc2.d/S90mysql
  • path
echo "export PATH=/usr/local/mysql/bin:$PATH" >> /etc/profile
  • my.cnf
  • ---------------------------------------------------------------------------------------------------------
  • #
    # The MySQL database server configuration file.
    #
    # You can copy this to one of:
    # - "/etc/mysql/my.cnf" to set global options,
    # - "~/.my.cnf" to set user-specific options.

    # One can use all long options that the program supports.
    # Run program with --help to get a list of available options and with
    # --print-defaults to see which it would actually understand and use.
    #
    # For explanations see
    # http://dev.mysql.com/doc/mysql/en/server-system-variables.html


    # This will be passed to all mysql clients
    # It has been reported that passwords should be enclosed with ticks/quotes
    # escpecially if they contain "#" chars...
    # Remember to edit /etc/mysql/debian.cnf when changing the socket location.
    [client]
    port = 3306
    socket = /var/run/mysqld/mysqld.sock


    # Here is entries for some specific programs
    # The following values assume you have at least 32M ram


    # This was formally known as [safe_mysqld]. Both versions are currently parsed.
    [mysqld_safe]
    socket = /var/run/mysqld/mysqld.sock
    nice = 0


    [mysqld]
    #
    # * Basic Settings
    #
    user = mysql
    pid-file = /data/mysqld/mysqld.pid
    socket = /data/mysqld/mysqld.sock
    port  = 3306
    basedir = /data/mysql
    datadir = /data/mysqldb
    tmpdir = /tmp
    #lc-messages-dir = /usr/share/mysql
    skip-external-locking
    #
    # Instead of skip-networking the default is now to listen only on
    # localhost which is more compatible and is not less secure.
    #bind-address = localhost
    bind-address = 0.0.0.0




    #server-id=1;
    #binlog-do-db=boss #需要记录进制日志的数据库.如果有多个数据库可用逗号分隔,或者使用多个binlog-do-db选项 
    #binlog-ignore-db=mysql #不需要记录进制日志的数据库.如果有多个数据库可用逗号分隔,或者使用多个binlog-do-db选项 
    #replicate-do-db=boss #需要进行同步的数据库.如果有多个数据库可用逗号分隔,或者使用多个replicate-do-db选项 
    #replicate-ignore-db=mysql,information_schema #不需要同步的数据库.如果有多个数据库可用逗号分隔,或者使用多个replicate-ignore-db选项 
    #同步参数: 
    #保证slave挂在任何一台master上都会接收到另一个master的写入信息 
    #log-slave-updates
    #sync_binlog=1
    #auto_increment_offset=1
    #auto_increment_increment=2
    #slave-skip-errors=all #过滤掉一些没啥大问题的错误




    #
    # * Fine Tuning
    #
    key_buffer = 512M
    max_allowed_packet = 28M
    thread_stack = 256K
    thread_cache_size       = 64
    # This replaces the startup script and checks MyISAM tables if needed
    # the first time they are touched
    myisam-recover         = default
    max_connections        = 5000
    #table_cache            = 64
    #thread_concurrency     = 10
    #
    # * Query Cache Configuration
    #
    query_cache_limit = 1M
    query_cache_size        = 512M
    query_cache_type = 1
    #
    # * Logging and Replication
    #
    # Both location gets rotated by the cronjob.
    # Be aware that this log type is a performance killer.
    # As of 5.1 you can enable the log at runtime!
    #general_log_file        = /var/log/mysql/mysql.log
    #general_log             = 1
    #
    # Error log - should be very few entries.
    #
    log_error = /data/mysql/error.log
    #
    # Here you can see queries with especially long duration
    #log_slow_queries = /data/mysql/mysql-slow.log
    #long_query_time = 2
    #log-queries-not-using-indexes
    #
    # The following can be used as easy to replay backup logs or for replication.
    # note: if you are setting up a replication slave, see README.Debian about
    #       other settings you may need to change.
    server-id = 1
    #log_bin = /data/mysql/logbin/mysql-bin.log
    #expire_logs_days = 10
    #max_binlog_size         = 1000M
    #binlog_do_db = boss
    #binlog_ignore_db = mysql
    #
    # * InnoDB
    #
    # InnoDB is enabled by default with a 10MB datafile in /var/lib/mysql/.
    # Read the manual for more InnoDB related options. There are many!
    #
    # * Security Features
    #
    # Read the manual, too, if you want chroot!
    # chroot = /var/lib/mysql/
    #
    # For generating SSL certificates I recommend the OpenSSL GUI "tinyca".
    #
    # ssl-ca=/etc/mysql/cacert.pem
    # ssl-cert=/etc/mysql/server-cert.pem
    # ssl-key=/etc/mysql/server-key.pem
    #log_bin_trust_function_creators=1




    [mysqldump]
    quick
    quote-names
    max_allowed_packet = 16M


    [mysql]
    #no-auto-rehash # faster start of mysql but no tab completition


    [isamchk]
    key_buffer = 16M


    #
    # * IMPORTANT: Additional settings that can override those from this file!
    #   The files must end with '.cnf', otherwise they'll be ignored.
    #
    #!includedir /etc/mysql/conf.d/



评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值