程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 數據庫知識 >> MYSQL數據庫 >> MySQL綜合教程 >> MySQL°²×°Æª

MySQL°²×°Æª

編輯:MySQL綜合教程

MySQL°²×°Æª


»·¾³½éÉÜ
ϵͳ£ºCentOS 5.8 64λ

MySQL°æ±¾:mysql-5.6.22-linux-glibc2.5-x86_64

×¢Òâ:ÒÔ¶þ½øÖÆ°²×°¡£ÒòΪMySQLµÄ±àÒëÐèÒªºÜ³¤µÄʱ¼ä¡£

°²×°²½Öè
1.°²×°µÄÇ°ÆÚ×¼±¸¹¤×÷¡£
a.¹Ø±Õselinux
vim /etc/sysconfig/selinux
SELINUX=DISABLED

b.ÁÙʱ¹Ø±Õ
setenforce 0
c.¹Ø±Õ·À»ðǽ
service iptables stop

ÆäÖз½·¨aºÍ·½·¨bÈÎÑ¡Ò»¸ö£¬µ«ÊÇ·½·¨aÐèÒªÖØÆô·þÎñÆ÷²ÅÄÜÉúЧ¡£

2.¹ÙÍøÏÂÔØÐèÒª°²×°MySQLµÄ¶þ½øÖÆ°ü,ÏÂÔصݲװ°üÎÒ·ÅÔÚ/opt/softwareĿ¼ÏÂ
3.½âѹËõ°²×°°ü
a.mkdir /opt/mysql
b.cd /opt/mysql
c.tar -zxf /opt/software/mysql-5.6.22-linux-glibc2.5-x86_64.tar.gz
d.cd /usr/local
e.ln -s /opt/mysql/mysql-5.6.22-linux-glibc2.5-x86_64 mysql
4.´´½¨Óû§×éÒÔ¼°Óû§
a.groupadd mysql
b.useradd -g mysql -d /data/mysql/mysql_3306 -s /sbin/nologin mysql
5.´´½¨ÅäÖÃÎļþ
a.cp /usr/local/mysql/support-files/my-default.cnf /etc/my.cnf
6.³õʼ»¯Êý¾Ý¿â
a.mkdir -p /data/mysql/mysql_3306
b.chown -R mysql:mysql /data/mysql/ chown -R mysql:mysql /usr/local/mysql/
c.cd /usr/local/mysql
e. ./script/mysql_install_db -user=mysql --basedir=/usr/local/mysql --datadir=/data/mysql/mysql_3306
7.Ìí¼Ó»·¾³±äÁ¿
a.echo "PATH=$PATH:/usr/local/mysql/bin">>/etc/profile
b.source /etc/profile
8.Æô¶¯
a.cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld
b./etc/init.d/mysqld start
°²×°¹ý³Ì³öÏֵĴíÎó£º
1.ÔÚÆô¶¯Ê±±¨´í£º\

Õâ¸öʱºò²é¿´MySQLµÄ´íÎóÈÕÖ¾ÈçÏÂͼ:<†·Ÿ"http://www.Bkjia.com/kf/ware/vc/" target="_blank" class="keylink">vcD4KPHA+PGltZyBzcmM9"http://www.2cto.com/uploadfile/Collfiles/20141217/20141217091527127.png" alt="\">

³öÏÖÕâÖÖÎÊÌâ½â¾ö°ì·¨ÊÇ£º
a.ɾ³ý/data/mysql/mysql_3306Ŀ¼ÏµÄËùÓÐÎļþ
b.Ôٴγõʼ»¯Êý¾Ý¿â
./mysql_install_db -user=mysql --basedir=/usr/local/mysql --datadir=/data/mysql/mysql_3306 --ldata=/data/mysql/mysql_3306/data

µ±È»³õʼ»¯Êý¾Ý»¹ÓÐÁíÍâµÄÒ»ÖÖ·½Ê½./mysql_install_db -user=mysql --defautls-file=/etc/my.cnf¡£×îºóÐèÒª¼ÇסµÄÊdzõʼ»¯Êý¾Ý¿âÒ»¶¨ÒªÔÚbasedirϽøÐС£

ÎÒÄ¿Ç°ÔÚ°²×°µÄʱºò¾Í³öÏÖÁËÕâôһ¸öÎÊÌ⣬ҪÊÇ»¹³öÏÖÆäËûµÄÎÊÌâ¿ÉÒÔÁôÑÔ½»Á÷£¬Ï±ßÊÇÎÒµÄÅäÖÃÎļþ¡£

[root@localhost support-files]# cat /etc/my.cnf 
#my.cnf
[client]
port            = 3306
socket          = /tmp/mysql.sock

[mysql]
prompt="\\u@\\h:\p  \\R:\\m:\\s [\\d]>"
#tee=/data/mysql/mysql_3306/data/query.log
no-auto-rehash

[mysqld_multi]
mysqld = /usr/local/mysql/bin/mysqld_safe
mysqladmin = /usr/local/mysql/bin/mysqladmin
log = /opt/mysql/mysqld_multi.log

[mysqld]
#misc
user = mysql
basedir = /usr/local/mysql
datadir = /data/mysql/mysql_3306/data
port = 3306
socket = /tmp/mysql.sock
event_scheduler = 0

#timeout
interactive_timeout = 300
wait_timeout = 300

#character set
character-set-server = utf8

open_files_limit = 65535
max_connections = 100
max_connect_errors = 100000

skip-name-resolve = 1
#logs
log-output=file
slow_query_log = 1
slow_query_log_file = slow.log
log-error = error.log
log_warnings = 2
pid-file = mysql.pid
long_query_time = 1
#log-slow-admin-statements = 1
#log-queries-not-using-indexes = 1
log-slow-slave-statements = 1


#binlog
binlog_format = mixed
server-id = 203306
log-bin = mybinlog
binlog_cache_size = 4M
max_binlog_size = 1G
max_binlog_cache_size = 2G
sync_binlog = 0
expire_logs_days = 10

#relay log
skip_slave_start = 1
max_relay_log_size = 1G
relay_log_purge = 1
relay_log_recovery = 1
log_slave_updates
#slave-skip-errors=1032,1053,1062

explicit_defaults_for_timestamp=1
#buffers & cache
table_open_cache = 2048
table_definition_cache = 2048
table_open_cache = 2048
max_heap_table_size = 96M
sort_buffer_size = 2M
join_buffer_size = 2M
thread_cache_size = 256
query_cache_size = 0
query_cache_type = 0
query_cache_limit = 256K
query_cache_min_res_unit = 512
thread_stack = 192K
tmp_table_size = 96M
key_buffer_size = 8M
read_buffer_size = 2M
read_rnd_buffer_size = 16M
bulk_insert_buffer_size = 32M

#myisam
myisam_sort_buffer_size = 128M
myisam_max_sort_file_size = 10G
myisam_repair_threads = 1

#innodb
innodb_buffer_pool_size = 100M
innodb_buffer_pool_instances = 1
innodb_data_file_path = ibdata1:1G:autoextend
innodb_flush_log_at_trx_commit = 2
innodb_log_buffer_size = 64M
innodb_log_file_size = 500M
innodb_log_files_in_group = 3
innodb_max_dirty_pages_pct = 50
innodb_file_per_table = 1
innodb_rollback_on_timeout
innodb_status_file = 1
innodb_io_capacity = 2000
transaction_isolation = READ-COMMITTED
innodb_flush_method = O_DIRECT

#¶Ë¿ÚºÅΪ3306µÄʵÀýÌØÊâÅäÖÃ
[mysqld3306]
port =3306 
server-id=203306
#Ö¸¶¨±¾ÊµÀýÏàÓ¦°æ±¾µÄbasedirºÍdatadir
basedir= /usr/local/mysql
datadir = /data/mysql/mysql_3306/data
socket          = /tmp/mysql_3306.sock
#ÖØÐÂÅäÖÃÕ⼸¸öÑ¡Ï²»ÓëÈ«¾ÖÅäÖÃÒ»Ñù£¬»áÖ±½Ó¸²¸ÇÉÏÃæµÄÈ«¾ÖÉèÖÃ
innodb_buffer_pool_size = 100m
#transaction_isolation = REPEATABLE-READ

[mysqld3308]
port=3308
server-id=203308
#binlog-do-db=db01
basedir= /usr/local/mysql
datadir = /data/mysql/mysql_3308/data
socket          = /tmp/mysql_3308.sock
#ÖØÐÂÅäÖÃÕ⼸¸öÑ¡Ï²»ÓëÈ«¾ÖÅäÖÃÒ»Ñù£¬»áÖ±½Ó¸²¸ÇÉÏÃæµÄÈ«¾ÖÉèÖÃ
innodb_buffer_pool_size = 100m
innodb_flush_log_at_trx_commit = 2
sync_binlog = 0


[mysqld3309]
port=3309
server-id=203309
#binlog-do-db=db01
basedir= /usr/local/mysql
datadir = /data/mysql/mysql_3309/data
socket          = /tmp/mysql_3309.sock
#ÖØÐÂÅäÖÃÕ⼸¸öÑ¡Ï²»ÓëÈ«¾ÖÅäÖÃÒ»Ñù£¬»áÖ±½Ó¸²¸ÇÉÏÃæµÄÈ«¾ÖÉèÖÃ
innodb_buffer_pool_size = 100m
innodb_flush_log_at_trx_commit = 2
sync_binlog = 0


  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved