MySQL5.5.24編譯安裝
MySQL5.5.24編譯安裝(親測)首先從官網下載mysql.tar.gz 壓縮包
當然也有mysql的rpm包 rpm 包安裝起來就比較簡單啦
由於mysql5 以上版本都開始用cmake方式編譯安裝
所以我們要先安裝好cmake
yum –y install gcc gcc-c++ gcc-g77 autoconf automake zlib* fiex* libxml*
ncurses-devel libmcrypt* libtool-ltdl-devel* cmake make
編譯安裝mysql5.5
首先新增使用者及組
groupadd mysql
useradd -g mysql mysql -s /sbin/nologin
建立mysql安裝資料夾及資料存放路徑
mkdir -p /usr/local/mysql
mkdirt -p /var/data/mysqldata
改變mysql資料資料夾的屬性
chown -R mysql:mysql
開始解壓安裝
tar -zxf mysql-5.5.24.tar.gz
cd mysql-5.5.24
cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql \ -----mysql安裝路徑
-DMYSQL_UNIX_ADDR=/data/mysql/mysql.sock \ ------mysql監聽sock位置
-DDEFAULT_CHARSET=utf8 \ ----mysql字元編碼方式
-DDEFAULT_COLLATION=utf8_general_ci \ --預設排序規則
-DWITH_EXTRA_CHARSETS:STRING=utf8,gbk \ 額外支援字符集
-DWITH_MYISAM_STORAGE_ENGINE=1 \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DWITH_MEMORY_STORAGE_ENGINE=1 \
-DWITH_READLINE=1 \
-DENABLED_LOCAL_INFILE=1 \
-DMYSQL_DATADIR=/data/mysql \ -----mysql資料存放位置
-DMYSQL_USER=mysql \ ------mysql 安裝使用者名稱
-DMYSQL_TCP_PORT=3306 ------mysql 監聽埠
如果沒報錯 繼續
cmake -DCMAKE_INSTALL_PREFIX=/data/mysql -DMYSQL_UNIX_ADDR=/data/mysql/mysql.sock -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DWITH_EXTRA_CHARSETS:STRING=utf8,gbk -DWITH_MYISAM_STORAGE_ENGINE=1 -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_MEMORY_STORAGE_ENGINE=1 -DWITH_READLINE=1 -DENABLED_LOCAL_INFILE=1 -DMYSQL_DATADIR=/data/mysql/data -DMYSQL_USER=mysql -DMYSQL_TCP_PORT=3306
make
make install
安裝完後要進行資料庫的初始化
cd /usr/local/mysql
cp support-files/my-medium.cnf /etc/my.cnf 複製配置檔案
cp support-files/mysql-server /etc/init.d/mysqld 複製到系統
chmod 755 /etc/init.d/mysqld 修改屬性
chkconfig --add /etc/init.d/mysqld -------新增為服務
chkconfig mysqld --level 235 on 設定在235 級別是開機自動執行
mysql_install_db
應該是你安裝完成mysql之後 在bin目錄下的
1
|
/usr/local/mysql/bin/mysql_install_db --user=mysql --datadir= /usr/local/mysql/var --skip-name-resolve |
一般是這樣
這個是初始化mysql資料庫的命令 非安裝mysql
[client]
#password = your_password
port = 3306
socket = /data/mysql/mysql.sock
default-character-set=utf8
# Here follows entries for some specific programs
# The MySQL server
[mysqld]
port = 3306
character_set_server=utf8
basedir=/data/mysql
datadir=/data/mysql/data
socket = /data/mysql/mysql.sock
skip-external-locking
key_buffer_size = 16M
max_allowed_packet = 1M
table_open_cache = 64
sort_buffer_size = 512K
net_buffer_length = 8K
read_buffer_size = 256K
read_rnd_buffer_size = 512K
myisam_sort_buffer_size = 8M
啟動mysql
service mysqld start
如果報錯
Starting MySQL. ERROR! The server quit without updating PID file (/data/mysql/rhelubuntu.com.pid).
則修改
vim /etc/init.d/mysqld
修改basedir=/usr/local/mysql -----mysql安裝位置
修改datadir=/var/data/mysqldata -----mysql資料檔案存放位置
一般修改好這個再重新啟動mysql應該不會報錯了
修改mysql 管理員密碼
mysqladmin -u root password
輸入新密碼
mysql 遠端登入
grant all on *.* to root@'%' identified by'pwd@123'
////////////(.代表所有的資料庫,當然也可以選擇其他的資料庫)
////////////(root 是使用者名稱,一樣也可以選擇其他使用者名稱)
////////////(%代表所有的ip地址)
////////////(這個‘password’裡面的內容是root使用者的密碼);
flush privileges; 重新整理許可權
mysql 新增使用者
grant all privileges on test.* on
z460@'%' identifiled by ‘password’
///////其中all privileges 表示所有的許可權 ,當然我們也可以授予select ,update,drop ,create等許可權
////////其中test 表示test資料庫
////////z460表示 使用者名稱
////////%表示所有的ip地址
////////password表示z460使用者的密碼
flush privileges ;
02.mysql 5.5.24安裝步驟 03. 04.下載: 05. 06.wget
ftp://ftp.easynet.be/mysql/Downloads/MySQL-5.5/mysql-5.5.24.tar.gz 07.yum install gcc gcc-c++ libtool autoconf -y 08.yum install automake imake libxml2-devel expat-devel ncurses-devel cmake bison -y 09.tar zxvf mysql-5.5.24.tar.gz 10.cd mysql-5.5.24
11.cmake \ 12.-DCMAKE_INSTALL_PREFIX=/usr/local/mysql \ 13.-DMYSQL_DATADIR=/home/mysql/ \ 14.-DWITH_MYISAM_STORAGE_ENGINE=1 \ 15.-DWITH_INNOBASE_STORAGE_ENGINE=1 \ 16.-DWITH_ARCHIVE_STORAGE_ENGINE=1 \ 17.-DWITH_BLACKHOLE_STORAGE_ENGINE=1 \ 18.-DENABLED_LOCAL_INFILE=1
\ 19.-DDEFAULT_CHARSET=utf8 \ 20.-DDEFAULT_COLLATION=utf8_general_ci \ 21.-DEXTRA_CHARSETS=all \ 22.-DWITH_SSL=system \ 23.-DMYSQL_TCP_PORT=3306 24.make 25.make install 26.cd /usr/local/mysql 27.chown -R mysql . 28.chgrp -R mysql . 29.cp support-files/mysql.server
/etc/init.d/mysqld 30.chmod +x /etc/init.d/mysqld 31. 32./usr/local/mysql/scripts/mysql_install_db --user=mysql --basedir=/usr/local/mysql --datadir=/data/mysql & 33.vim /etc/my.cnf 34.[client] 35.port = 3306 36.socket = /tmp/mysql.sock 37. 38.#
The MySQL server 39.[mysqld] 40.port = 3306 41.socket = /tmp/mysql.sock 42.datadir = /data/mysql 43. 44.skip-name-resolve 45.skip-external-locking 46. 47.table_open_cache = 70 48.read_buffer_size = 256K 49.read_rnd_buffer_size = 512K
50.thread_concurrency=16 51.########################### INNODB ############################ 52.innodb_file_per_table=1 53.innodb_buffer_pool_size=20M 54.innodb_flush_log_at_trx_commit=0 55.#init_connect='SET autocommit=0' 56.innodb_log_file_size=40M 57.innodb_additional_mem_pool_size=16M
58.innodb_log_buffer_size=6M 59.innodb_doublewrite=0 60.innodb_max_dirty_pages_pct=80 61.innodb_flush_method=O_DIRECT 62.innodb_thread_concurrency=0 63. 64.####################### Connections ########################## 65.#back_log = 500 66.max_connections=1024
67.max_connect_errors=99999 68.max_allowed_packet = 2M 69.table_cache=4096 70.thread_cache=64 71.open_files_limit = 10000 72.net_buffer_length = 8K 73. 74.####################### Buffer Size ########################### 75.key_buffer = 3072M 76.max_heap_table_size
= 32M 77.myisam_sort_buffer_size = 8M 78.#query_cache_size = 128M 79.sort_buffer_size = 512K 80.tmp_table_size = 64M 81. 82.############################################################### 83.interactive_timeout=30 84.wait_timeout=30 85.connect_timeout=10
86. 87.#slow-query-log 88.#long_query_time=2 89.slow-query-log 90.slow_launch_time=2 91.slow-query-log-file=/data/mysql/db001-slow.log 92. 93.######################## Master-Slave ######################## 94. 95.server-id=1 96. 97.log-bin=mysql-bin
98.binlog_format=mixed 99.log_slave_updates= 1 100. 101.expire_logs_days=30 102.lower_case_table_names=1 103. 104.slave-skip-errors=all 105. 106.############################################################## 107.[mysqldump] 108.quick 109.max_allowed_packet
= 16M 110. 111.[mysql] 112.no-auto-rehash 113. 114.[isamchk] 115.key_buffer = 8M 116.sort_buffer_size = 8M 117. 118.[myisamchk] 119.key_buffer = 8M 120.sort_buffer_size = 8M 121. 122.[mysqlhotcopy] 123.interactive-timeout 124.##增加系統服務 125./sbin/chkconfig
--add mysqld 126./sbin/chkconfig mysqld on 127./sbin/service mysqld start 128.netstat -tnlp |grep 3306 129.export PATH=$PATH:/usr/local/mysql/bin/ 130. 131.mysql 5.5.24 132.主從配置 133.master 192.168.0.211 134.slave 192.168.0.210 135. 136.在master的配置檔案中加上
137.server-id = 1 138.binlog-do-db = test01 139.binlog-ignore-db = mysql 140.在slave的配置檔案上加上 141.server-id = 2 142.relay-log=server02-relay-bin 143.replicate-do-db = test01 144.replicate-ignore-db=mysql 145.relay-log-index=slave-relay-bin.index 146.###master的資訊不用再加到slave的配置檔案中
否則重啟mysql引起找不到pid檔案 master的資訊只在從庫中執行change語句裡面執行 147.分別重啟資料庫 148.在master上看一下以下資訊 149.mysql> show master status; 150.+------------------+----------+--------------+------------------+ 151.| File | Position | Binlog_Do_DB | Binlog_Ignore_DB | 152.+------------------+----------+--------------+------------------+
153.| mysql-bin.000008 | 199 | test01 | mysql | 154.+------------------+----------+--------------+------------------+ 155.並執行一下語句: 156.mysql> create database test01; 157.mysql> GRANT REPLICATION SLAVE,REPLICATION CLIENT,RELOAD,SUPER ON *.* TO'slave'@'192.168.0.210'
IDENTIFIED BY '123456'; 158.mysql> Grant ALL PRIVILEGES ON test01.* TOslave@'%' IDENTIFIED BY '123456'; 159.在slave上執行一下語句 160.mysql> CHANGE MASTER TO MASTER_HOST='192.168.0.211', MASTER_PORT=3306,MASTER_USER='slave',
MASTER_PASSWORD='123456',master_log_file = 'mysql-bin.000008', master_log_pos = 199; 161.mysql> slave start; 162.mysql> show slave status\G 163.能看到Slave_IO_Running: Yes 164.Slave_SQL_Running: Yes說明同步成功 165. 166. 167.mysql5.1與5.5主從配置的差異 168.1.master資訊不再在從庫的配置檔案中指定,而是直接在從庫的sql命令中使用change
master語句指定 169. 170.2.Server-id的規則: 171.Server ID. On the master and each slave, you must use the server-id option to establish a unique replication ID in the range from 1 to 232 – 1. “Unique” means that each ID must be different from every other ID in use
by any other replication master or slave. 172.主庫ID為1,從庫id的取值範圍為2-232 – 1 但每個slave的id必須唯一 173. 174.此外官方推薦的配置配置檔案中指出: 175.# required unique id between 2 and 2^32 – 1 #從庫ID取值範圍為2-232 – 1 176.# (and different from the master) #必須和主庫區別開 177.# defaults to 2
if master-host is set #預設設定為2 如果只有一個從庫 178.# but will not function as a slave if omitted #如果對id不做設定,從庫將不起作用 179. 180.3。在5.5從機中,skip-slave-errors=all是繼續有效,但是官方文件給出的解釋如下: 181.? --slave-skip-errors=[err_code1,err_code2,...|all] 182.Normally, replication stops
when an error occurs on the slave. This gives you the opportunity to resolve the inconsistency in the 183.data manually. This option tells the slave SQL thread to continue replication when a statement returns any of the errors listed in 184.the option value.
185.正常情況下,當從庫複製出現出現錯誤時,複製將暫停,這樣就有了解決資料不一致的機會。此選項的作用是,當此選項值等於mysql返回的錯誤碼[err_code* 、ALL]時複製繼續進行 186.Do not use this option unless you fully understand why you are getting errors. If there are no bugs in your replication setup and 187.client programs, and
no bugs in MySQL itself, an error that stops replication should never occur. Indiscriminate use of this option 188.results in slaves becoming hopelessly out of synchrony with the master, with you having no idea why this has occurred. 189.不建議使用此選項,除非你可以斷定什麼原因導致了這些錯誤,如果在複製設定、客戶端程式、以及mysql本身無bugs,能使複製程式停止的錯誤是不可能發生的,濫用此選項將會導致無法理想的與主庫同步,而且你會對此不同步的原因將毫不知情
190.4.MySQL 5.5的二進位制日誌記錄格式為MAXED 191.mysql> select @@session.binlog_format; 192.+-------------------------+ 193.| @@session.binlog_format | 194.+-------------------------+ 195.| MIXED | 196.+-------------------------+ 197.1 row in set (0.00 sec)
相關文章
- 編譯安裝zabbix編譯
- apache編譯安裝Apache編譯
- 編譯安裝nmon編譯
- swoole 編譯安裝編譯
- 編譯安裝Nginx編譯Nginx
- 編譯安裝mysql編譯MySql
- nginx編譯安裝Nginx編譯
- 安裝編譯ffmpeg編譯
- Griffin編譯安裝編譯
- Shell編譯安裝nginx編譯Nginx
- centos PHP 編譯安裝CentOSPHP編譯
- httpd編譯安裝phphttpd編譯PHP
- PHP的編譯安裝PHP編譯
- Mysql 5.7.17 編譯安裝MySql編譯
- ffmpeg安裝之linux編譯安裝Linux編譯
- CentOS 下編譯安裝 NginxCentOS編譯Nginx
- CentOS 下編譯安裝 apacheCentOS編譯Apache
- Mac 編譯安裝 PHPRedis 模組Mac編譯PHPRedis
- PHP7 編譯安裝PHP編譯
- Linux編譯安裝NginxLinux編譯Nginx
- CentOS 6.4 編譯安裝 apacheCentOS編譯Apache
- ubuntu編譯安裝kernel教程。Ubuntu編譯
- windows下編譯安裝thriftWindows編譯
- 編譯安裝php7編譯PHP
- php7編譯安裝PHP編譯
- 原始碼編譯安裝Redis原始碼編譯Redis
- 編譯安裝LAMP環境編譯LAMP
- LNMP—Nginx的編譯安裝LNMPNginx編譯
- LAMP原始碼編譯安裝LAMP原始碼編譯
- php5.5.38編譯安裝PHP編譯
- PHP編譯安裝引數PHP編譯
- LNMP編譯安裝配置+discuzLNMP編譯
- ubuntu thrift 0.9.3編譯安裝Ubuntu編譯
- 編譯安裝php5.6.2編譯PHP
- ubuntu下 編譯安裝swftoolsUbuntu編譯
- Centos 下編譯安裝RedisCentOS編譯Redis
- 編譯安裝CoreSeek-4.1編譯
- MySQL 5.6.19編譯安裝MySql編譯