快捷搜索:  as  2018  FtCWSyGV  С˵  test  xxx  Ψһ  w3viyKQx

澳门新葡亰平台游戏APP:Centos Linux下源码安装MySQL 5.6教程



本文主要先容centos下源码安装MySQL 5.6的措施,centos的版本为5.8.

1)首先,你必要到MySQL官网下载源码tar包,点击MySQL Community Server,选择Source Code,源码包不大年夜,只有34M阁下。

注:以下操作没有特殊阐明,都因澳门新葡亰平台游戏APP此root账户履行。

2)先安装cmake(mysql5.5今后源码安装都得经由过程cmake编译)

# yum install cmake

并确保以下两个包已安装最新版:

ncurses

ncurses-devel

3)添加MySQL用户组和用户

# groupadd mysql

# useradd -g mysql mysql

4)创建MySQL软件安装目录和数据寄放目录

mkdir -p /opt/mysql#MySQL安装目录

chown -R mysql:mysql /opt/mysql

mkdir -p /data/mysql#MySQL数据寄放目录

mkdir -p /data/mysql/data #寄放数据

mkdir -p /data/mysql/log#寄放日志

mkdir -p /data/mysql/tmp#寄放临时文件

chown -R mysql:mysql /data/mysql

5)cmake编译安装MySQL

tar zxvf mysql-5.6.13.tar.gz

cd mysql-5.6.13

cmake . -DCMAKE_INSTALL_PREFIX=/opt/mysql -DMYSQL_DATADIR=/data/mysql -DSYSCONFDIR=/opt/mysql -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci-DEXTRA_CHARSETS=all -DENABLED_LOCAL_INFILE=1

make

make install

参数阐明:

-DCMAKE_INSTALL_PREFIX=/opt/mysql//指定安装目录

-DINSTALL_DATADIR=/data/mysql//指定命据寄放目录

-DSYSCONFDIR=/opt/mysql//指定设置设置设备摆设摆设文件目录(本例的设置设置设备摆设摆设文件为/opt/mysql/my.cnf)

-DDEFAULT_CHARSET=utf8//指定字符集

-DDEFAULT_COLLATION=utf8_general_c澳门新葡亰平台游戏APPi//指定校验字符

-DEXTRA_CHARSETS=all//安装所有扩展字符集

-DENABLED_LOCAL_INFILE=1//容许从本地导入数据

上述步骤履行成功后,MySQL软件已成功安装至/opt/mysql目录下。

7)编辑设置设置设备摆设摆设文件my.cnf

[client]

socket = /opt/mysql/run/mysql.sock

[innotop]

socket = /opt/mysql/run/mysql.sock

[mysql]

prompt = \u@\d \r:\m:\s>

no-auto-rehash

[mysqld_safe]

pid-file = /opt/mysql/run/mysqld.pid

[mysqld]

#### Baes dir ####

basedir = /opt/mysql

datadir = /data/mysql/data

tmpdir = /data/mysql/tmp

socket = /opt/mysql/run/mysql.sock

#### Base configure info ####

port = 3306

skip-name-resolve

old_passwords = 0

lower_case_table_names = 1

open_files_limit = 65535

read_rnd_buffer_size = 5M

max_allowed_packet = 24M

max_connect_errors = 50000

max_connections = 1000

max_user_connections = 950

thread_cache_size=64

table_open_cache=1024

thread_stack=262144

wait_timeout=864000

#### Log info ####

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

slow_query_log=1

slow_query_log_file= /data/mysql/log/slow.log

log-slow-admin-statements

long_query_time = 0.1

slow_launch_time=1

#### Binary log && Relay log ####

binlog_format='MIXED'

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

log-slave-updates = 1

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

relay-log-index = /data/mysql/log/mysqld-relay-bin.index

master-info-file = /data/mysql/log/master.info

relay-log-info-file = /data/mysql/log/relay-log.info

max_binlog_size = 500M

max_binlog_cache_size = 2G

#### query cache ####

query_cache_size = 100M

query_cache_limit = 1K

query_cache_min_res_unit = 1K

query_cache_type=2

#myisam

concurrent_insert = 2

key_buffer_size = 100M

sort_buffer_size = 100K

join_buffer_size = 100K

read_buffer_size = 1M

myisam_sort_buffer_size = 100M

#innodb plugin

#innodb

default-storage-engine = INNODB

innodb_flush_method = O_DIRECT

innodb_file_per_table = 1

innodb_open_files=60000

innodb_flush_log_at_trx_commit = 2

innodb_lock_wait_timeout = 100

innodb_additional_mem_pool_size = 20M

innodb_buffer_pool_size = 16G

innodb_log_buffer_size= 400M

inno澳门新葡亰平台游戏APPdb_log_file_size = 100M

innodb_log_files_in_group = 4

innodb_file_io_threads = 4

innodb_thread_concurrency = 16

innodb_max_dirty_pages_pct = 50

transaction-isolati澳门新葡亰平台游戏APPon = READ-COMMITTED

innodb_data_file_path = ibdata1:10G;ibdata2:5G:autoextend

innodb_buffer_pool_instances=4

innodb_thread_concurrency=32

### Server id ####

log_bin_trust_function_creators=1

read_only=0

server_id=5

8)创建数据库

/opt/mysql/scripts/mysql_install_db--user=mysql

上述建库语句将根据my.cnf里设置的数据文件目录和日志文件目录,天生响应的数据文件和日志文件,并创建系统数据库(如mysql,test,information_schema,performance_schema)

9)启动MySQL

/opt/mysql/support-files/mysql.server start

启动成功后,就可以以root用户登录(默认的root用户没有密码)

/opt/mysql/bin/mysql -u root

10)设置root密码,创建只读账号

export PATH=$PATH:/opt/mysql/bin

mysqladmin -u root password '奸淫'

mysql -uroot -p

root@(none) 06:08:34>GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '奸淫' WITH GRANT OPTION;

root@(none) 06:08:44>GRANT SELECT ON *.* TO 'rnd'@'%' IDENTIFIE澳门新葡亰平台游戏APPD BY '奸淫';

11)着末,把MySQL加入系统启动项和开机启动

cp ./support-files/mysql.server /etc/rc.d/init.d/mysqld #把Mysql加入系统启动

chmod 755 /etc/init.d/mysqld #增添履行权限

chkconfig mysqld on #加入开机启动

这样,履行service mysqld start即可启动MySQL了:)。

您可能还会对下面的文章感兴趣: