mysql libs 5.6.27_编译mysql5.6.27

yum install gcc gcc-c++ bzip2-devel bzip2-libs python-devel ncurses-devel bison perl-Module-Install.noarch -y

cd /usr/local/src/

wget "http://distfiles.macports.org/cmake/cmake-3.10.2.tar.gz"

tar -zxvf cmake-3.10.2.tar.gz

cd cmake-3.10.2

./bootstrap

gmake && gmake install

cd ..

wget "http://mirror.neu.edu.cn/mysql/Downloads/MySQL-5.6/mysql-5.6.27.tar.gz"

或者 wget "http://mirror.neu.edu.cn/mysql/Downloads/MySQL-5.7/mysql-5.7.10.tar.gz"

tar -zxvf mysql-5.6.27.tar.gz

cd mysql-5.6.27

cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql-5.6.27 \

-DMYSQL_DATADIR=/data/mysql/ \

-DSYSCONFDIR=/etc \

-DWITH_MYISAM_STORAGE_ENGINE=1 \

-DWITH_INNOBASE_STORAGE_ENGINE=1 \

-DWITH_MEMORY_STORAGE_ENGINE=1 \

-DWITH_READLINE=1 \

-DMYSQL_UNIX_ADDR=/data/mysql/mysql.sock \

-DMYSQL_TCP_PORT=4568 \

-DENABLED_LOCAL_INFILE=1 \

-DWITH_PARTITION_STORAGE_ENGINE=1 \

-DEXTRA_CHARSETS=all \

-DDEFAULT_CHARSET=utf8 \

-DDEFAULT_COLLATION=utf8_general_ci

make && make install

创建mysql目录级修改权限

groupadd mysql

useradd -M -s /sbin/nologin -g mysql mysql

mkdir -p /data/mysql/data

mkdir -p /data/mysql/log

chown mysql.mysql -R /data/mysql/

主配置

vi /etc/my.cnf

[client]

port = 4568

socket = /data/mysql/log/mysql.sock

[mysqld]

user = mysql

port = 4568

character-set-server = utf8

default-storage-engine = InnoDB

socket = /data/mysql/log/mysql.sock

pid-file = /data/mysql/log/mysql.pid

# DATA STORAGE #

datadir = /data/mysql/data

innodb_data_file_path = ibdata1:1024M:autoextend

innodb_data_home_dir = /data/mysql/data

innodb_log_group_home_dir = /data/mysql/data

# MyISAM #

key-buffer-size = 16M

# SAFETY #

back_log = 512

max-allowed-packet = 16M

max-connect-errors = 1000

wait_timeout = 100

interactive_timeout = 100

skip-name-resolve

skip-external-locking

event_scheduler = OFF

explicit-defaults-for-timestamp =1

sysdate-is-now = 1

innodb = FORCE

# BINARY LOGGING #

#log-bin = /data/mysql/log/mysql-bin

log-bin = /data/mysql/log/mysql-bin

binlog-format = mixed

expire-logs-days = 7

sync-binlog = 100

binlog_cache_size = 8M

# REPLICATION #

server-id = 4

relay-log = /data/mysql/log/relay-bin

slave-net-timeout = 60

# CACHES AND LIMITS #

tmp-table-size = 512M

max-heap-table-size = 64M

query-cache-type = 0

query-cache-size = 0

max-connections = 500

thread-cache-size = 2000

open-files-limit = 65535

table-definition-cache = 4096

table-open-cache = 20480

transaction_isolation = READ-COMMITTED

skip-external-locking = 1

# INNODB #

innodb-flush-method = O_DIRECT

innodb-log-files-in-group = 2

innodb-log-file-size = 256M

innodb-buffer-pool-size = 4G

innodb_read_io_threads = 4

innodb_write_io_threads = 4

innodb_io_capacity = 500

innodb_strict_mode = 1

innodb_file_format = Barracuda

innodb_file_format_max = Barracuda

innodb_purge_threads = 1

innodb_use_sys_malloc

innodb_additional_mem_pool_size = 8M

innodb-flush-log-at-trx-commit = 2

innodb-file-per-table = 1

innodb_support_xa = 0

# BUFFER #

read_buffer_size = 2M

join_buffer_size = 2M

sort_buffer_size = 2M

# LOGGING #

log-error = /data/mysql/log/mysql-error.log

log-queries-not-using-indexes = 0

slow-query-log = 1

long_query_time = 2

slow-query-log-file = /data/mysql/log/mysql-slow.log

=======================

初始化

/usr/local/mysql-5.6.27/scripts/mysql_install_db --basedir=/usr/local/mysql-5.6.27 --datadir=/data/mysql/data --defaults-file=/etc/my.cnf

===================

创建快捷启动级开机服务启动

vi /lib/systemd/system/mysql.service

[Unit]

Description=The MYSQL Process Manager

After=network.target

[Service]

Type=forking

ExecStart=/usr/local/mysql-5.6.27/support-files/mysql.server start

ExecReload=/usr/local/mysql-5.6.27/support-files/mysql.server restart

ExecStop=/usr/local/mysql-5.6.27/support-files/mysql.server stop

PrivateTmp=true

[Install]

WantedBy=multi-user.target

chmod +x /lib/systemd/system/mysql.service

systemctl enable mysql.service

systemctl start mysql.service

=======================

启动mysql创建本地管理帐号及删除无密码帐号

/usr/local/mysql-5.6.27/bin/mysqladmin -u root password 'orange#123'

/usr/local/mysql-5.6.27/bin/mysql -uroot -p'orange#123' -e "delete from mysql.user where password='';"

/usr/local/mysql-5.6.27/bin/mysql -uroot -p'orange#123' -e "flush privileges;"

#添加环境变量

vi /etc/profile

#add path for mysql

MYSQL_PATH=/usr/local/mysql-5.6.27/bin/

PATH=$PATH:$MYSQL_PATH

export PATH MYSQL_PATH

创建用户

/usr/local/mysql-5.6.27/bin/mysql -uroot -p

create user 'orange'@'%' identified by 'Hu#jgh%GVhb@5dGf35';

grant all privileges on *.* to 'orange'@'%';

flush privileges;

//备份语句

/usr/local/mysql-5.6.27/bin/mysqldump -udumper -p‘back#123654’ -hlocalhost -P4568 orange > orange_`date +%F_%T`.sql

//还原语句

mysql -uroot -p123456 orange

主从

从库账号密码

/usr/local/mysql-5.6.27/bin/mysqladmin -u root password 'sd#dfJGR8674#@%fgjk'

创建从者账号

CREATE USER 'slaver'@'%' IDENTIFIED BY 'sd#dfJGR8674#@%fgjk';

GRANT REPLICATION SLAVE ON *.* TO 'slaver'@'%';

CHANGE MASTER TO MASTER_HOST='120.77.254.17',MASTER_USER='slaver',MASTER_PASSWORD='sd#dfJGR8674#@%fgjk',MASTER_LOG_FILE='mysql-bin.000009',MASTER_LOG_POS=120;

你可能感兴趣的:(mysql,libs,5.6.27)