亚洲综合社区欧美综合色-欧美逼逼一区二区三区-国产老熟女高潮精品网站-国产日韩最新视频在线看

始創(chuàng)于2000年 股票代碼:831685
咨詢熱線:0371-60135900 注冊(cè)有禮 登錄
  • 掛牌上市企業(yè)
  • 60秒人工響應(yīng)
  • 99.99%連通率
  • 7*24h人工
  • 故障100倍補(bǔ)償
全部產(chǎn)品
您的位置: 網(wǎng)站首頁(yè) > 幫助中心>文章內(nèi)容

CentOS 5.4 x86_64 編譯安裝 MySQL 完全筆記

發(fā)布時(shí)間:  2012/8/14 17:16:50

MySQL編譯安裝筆記
大前提,你的Linux系統(tǒng)要搭建好GCC的編譯環(huán)境。
使用CentOS的話可以:
yum -y install gcc
yum -y install gcc-c++
添加MySQL用戶組和用戶
grounadd mysql
useradd -g mysql mysql
MySQL編譯安裝依賴的軟件包:
cd /tmp
-
 

wget http://ftp.gnu.org/pub/gnu/ncurses/ncurses-5.7.tar.gz
tar -zvxf ncurses-5.7.tar.gz
cd ncurses-5.7
./configure --prefix=/usr --with-shared --without-debug
make
make install

修改MySQL最大連接數(shù),解開MySQL的原代碼,進(jìn)入里面的sql目錄修改mysqld.cc找到下面一行:
{"max_connections", OPT_MAX_CONNECTIONS,
"The number of simultaneous clients allowed.", (gptr*) &max_connections,(gptr*) &max_connections, 0, GET_ULONG, REQUIRED_ARG, 151, 1, 16384, 0, 1,0},
把它改為:
{"max_connections", OPT_MAX_CONNECTIONS,"The number of simultaneous clients allowed.", (gptr*) &max_connections,(gptr*) &max_connections, 0, GET_ULONG, REQUIRED_ARG, 1500, 1, 16384, 0, 1,0},
編譯安裝MySQL:
cd /tmp
wget http://mirrors.sohu.com/mysql/MySQL-5.5/mysql-5.5.2-m2.tar.gz
tar -zvxf mysql-5.5.2-m2.tar.gz
cd mysql-5.5.2-m2
CFLAGS="-O3" CXX=gcc CXXFLAGS="-O3 -felide-constructors -fno-exceptions -fno-rtti -fomit-frame-pointer -ffixed-ebp"
./configure --prefix=/usr/local/mysql --enable-assembler --with-charset=utf8 --with-collation=utf8_general_ci --with-extra-charsets=all --enable-thread-safe-client --with-big-tables --with-readline --with-ssl --with-embedded-server --enable-local-infile --with-client-ldflags=-all-static --with-mysqld-ldflags=-all-static --with-plugins=partition,innobase,myisammrg
make
make install
在CentOS上安裝mysql時(shí),可能會(huì)停頓一段時(shí)間(mysql-test),多等等就過去了
安裝完成后,修改目錄權(quán)限:
chmod +w /usr/local/mysql
chown -R mysql:mysql /usr/local/mysql
建立一些必要的目錄:
mkdir -p /usr/local/mysql/data
mkdir -p /usr/local/mysql/binlog
mkdir -p /usr/local/mysql/relaylog
chown -R mysql:mysql /usr/local/mysql
使用mysql用戶帳號(hào)的身份建立數(shù)據(jù)表(www.linuxidc.com也可以說初始化mysql的數(shù)據(jù)庫(kù)):
/usr/local/mysql/bin/mysql_install_db --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data --user=mysql
創(chuàng)建MySQL的配置文件,配置文件名通常為my.cnf:
vi /usr/local/mysql/my.cnf
輸入以下內(nèi)容并保存:
[client]
character-set-server = utf8
port    = 3306
socket = /tmp/mysql.sock
[mysqld]
character-set-server = utf8
replicate-ignore-db = mysql
replicate-ignore-db = test
replicate-ignore-db = information_schema
user    = mysql
port    = 3306
socket = /tmp/mysql.sock
basedir = /usr/local/mysql
datadir = /usr/local/mysql/data
log-error = /usr/local/mysql/mysql_error.log
pid-file = /usr/local/mysql/mysql.pid
open_files_limit    = 10240
back_log = 600
max_connections = 5000
max_connect_errors = 6000
table_cache = 614
external-locking = FALSE
max_allowed_packet = 32M
sort_buffer_size = 1M
join_buffer_size = 1M
thread_cache_size = 300
thread_concurrency = 8
query_cache_size = 512M
query_cache_limit = 2M
query_cache_min_res_unit = 2k
default-storage-engine = MyISAM
thread_stack = 192K
transaction_isolation = READ-COMMITTED
tmp_table_size = 246M
max_heap_table_size = 246M
long_query_time = 3
log-slave-updates
log-bin = /usr/local/mysql/binlog/binlog
binlog_cache_size = 4M
binlog_format = MIXED
max_binlog_cache_size = 8M
max_binlog_size = 1G
relay-log-index = /usr/local/mysql/relaylog/relaylog
relay-log-info-file = /usr/local/mysql/relaylog/relaylog
relay-log = /usr/local/mysql/relaylog/relaylog
expire_logs_days = 30
key_buffer_size = 256M
read_buffer_size = 1M
read_rnd_buffer_size = 16M
bulk_insert_buffer_size = 64M
myisam_sort_buffer_size = 128M
myisam_max_sort_file_size = 10G
myisam_repair_threads = 1
myisam_recover
interactive_timeout = 120
wait_timeout = 120
skip-name-resolve
master-connect-retry = 10
slave-skip-errors = 1032,1062,126,1114,1146,1048,1396
#master-host     =   192.168.1.2
#master-user     =   username
#master-password =   password
#master-port     = 3306
server-id = 1
innodb_additional_mem_pool_size = 16M
innodb_buffer_pool_size = 512M
innodb_data_file_path = ibdata1:256M:autoextend
innodb_file_io_threads = 4
innodb_thread_concurrency = 8
innodb_flush_log_at_trx_commit = 2
innodb_log_buffer_size = 16M
innodb_log_file_size = 128M
innodb_log_files_in_group = 3
innodb_max_dirty_pages_pct = 90
innodb_lock_wait_timeout = 120
innodb_file_per_table = 0
#log-slow-queries = /usr/local/mysql/slow.log
#long_query_time = 10
[mysqldump]
quick
max_allowed_packet = 32M

創(chuàng)建管理MySQL數(shù)據(jù)庫(kù)的shell腳本:
vi /usr/local/mysql/mysql
輸入以下內(nèi)容并保存(這里的用戶名root和密碼123456接下來的步驟會(huì)創(chuàng)建):
#!/bin/sh
mysql_port=3306
mysql_username="root"
mysql_password="123456"
function_start_mysql()
{
    printf "Starting MySQL...\n"
    /bin/sh /usr/local/mysql/bin/mysqld_safe --defaults-file=/usr/local/mysql/my.cnf 2>&1 > /dev/null &
}
function_stop_mysql()
{
    printf "Stoping MySQL...\n"
    /usr/local/mysql/bin/mysqladmin -u ${mysql_username} -p${mysql_password} -S /tmp/mysql.sock shutdown
}
function_restart_mysql()
{
    printf "Restarting MySQL...\n"
    function_stop_mysql
    sleep 5
    function_start_mysql
}
function_kill_mysql()
{
    kill -9 $(ps -ef | grep 'bin/mysqld_safe' | grep ${mysql_port} | awk '{printf $2}')
    kill -9 $(ps -ef | grep 'libexec/mysqld' | grep ${mysql_port} | awk '{printf $2}')
}
if [ "$1" = "start" ]; then
    function_start_mysql
elif [ "$1" = "stop" ]; then
    function_stop_mysql
elif [ "$1" = "restart" ]; then
function_restart_mysql
elif [ "$1" = "kill" ]; then
function_kill_mysql
else
    printf "Usage: /usr/local/mysql/mysql {start|stop|restart|kill}\n"
fi
賦予MySQL數(shù)據(jù)庫(kù)的shell腳本可執(zhí)行權(quán)限:
chmod +x /usr/local/mysql/mysql
啟動(dòng)MySQL:
/usr/local/mysql/mysql start
通過命令行登錄管理MySQL服務(wù)器(提示輸入密碼時(shí)直接回車):
/usr/local/mysql/bin/mysql -u root -p -S /tmp/mysql.sock
輸入以下SQL語句,創(chuàng)建一個(gè)具有root權(quán)限的用戶(root)和密碼(123456):
GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost' IDENTIFIED BY '123456';
GRANT ALL PRIVILEGES ON *.* TO 'root'@'127.0.0.1' IDENTIFIED BY '123456';
停止MySQL命令:
/usr/local/mysql/mysql stop


本文出自:億恩科技【1tcdy.com】

服務(wù)器租用/服務(wù)器托管中國(guó)五強(qiáng)!虛擬主機(jī)域名注冊(cè)頂級(jí)提供商!15年品質(zhì)保障!--億恩科技[ENKJ.COM]

  • 您可能在找
  • 億恩北京公司:
  • 經(jīng)營(yíng)性ICP/ISP證:京B2-20150015
  • 億恩鄭州公司:
  • 經(jīng)營(yíng)性ICP/ISP/IDC證:豫B1.B2-20060070
  • 億恩南昌公司:
  • 經(jīng)營(yíng)性ICP/ISP證:贛B2-20080012
  • 服務(wù)器/云主機(jī) 24小時(shí)售后服務(wù)電話:0371-60135900
  • 虛擬主機(jī)/智能建站 24小時(shí)售后服務(wù)電話:0371-60135900
  • 專注服務(wù)器托管17年
    掃掃關(guān)注-微信公眾號(hào)
    0371-60135900
    Copyright© 1999-2019 ENKJ All Rights Reserved 億恩科技 版權(quán)所有  地址:鄭州市高新區(qū)翠竹街1號(hào)總部企業(yè)基地億恩大廈  法律顧問:河南亞太人律師事務(wù)所郝建鋒、杜慧月律師   京公網(wǎng)安備41019702002023號(hào)
      1
     
     
     
     

    0371-60135900
    7*24小時(shí)客服服務(wù)熱線