1、系統(tǒng)環(huán)境 CentOS 6.8_X64
讓客戶滿意是我們工作的目標(biāo),不斷超越客戶的期望值來自于我們對這個行業(yè)的熱愛。我們立志把好的技術(shù)通過有效、簡單的方式提供給客戶,將通過不懈努力成為客戶在信息化領(lǐng)域值得信任、有價值的長期合作伙伴,公司提供的服務(wù)項目有:國際域名空間、網(wǎng)頁空間、營銷軟件、網(wǎng)站建設(shè)、屏邊網(wǎng)站維護、網(wǎng)站推廣。
2、需要的軟件mirrors-alisql-master.zip 以及需要的依賴包centos-release-scl devtoolset-4-gcc-c++ devtoolset-4-gcc ncurses-devel openssl-devel bison git cmake
3、安裝需要的依賴軟件包
yum -y install centos-release-scl devtoolset-4-gcc-c++ devtoolset-4-gcc ncurses-devel openssl-devel bison git cmake
4、下載 mirrors-alisql-master.zip
https://github.com/alibaba/AliSQL
5、解壓mirrors-alisql-master.zip
unzip mirrors-alisql-master.zip
6、創(chuàng)建MySQL用戶組和用戶,及數(shù)據(jù)庫存放目錄:
mkdir -p /usr/local/mysql
mkdir -p /usr/local/mysql/tmp
mkdir -p /var/log/mysql
groupadd mysql
useradd mysql -g mysql -M -s /sbin/nologin
chown -R mysql.mysql /usr/local/mysql
chown -R mysql.mysql /var/log/mysql
7、編譯安裝
cd alisql
cmake . \
-DCMAKE_INSTALL_PREFIX=/usr/local/mysql \
-DMYSQL_DATADIR=/usr/local/mysql/data \
-DCMAKE_BUILD_TYPE="Release" \
-DWITH_EMBEDDED_SERVER=0 \
-DWITH_EXTRA_CHARSETS=all \
-DWITH_MYISAM_STORAGE_ENGINE=1 \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DWITH_PARTITION_STORAGE_ENGINE=1 \
-DWITH_CSV_STORAGE_ENGINE=1 \
-DWITH_ARCHIVE_STORAGE_ENGINE=1 \
-DWITH_BLACKHOLE_STORAGE_ENGINE=1 \
-DWITH_FEDERATED_STORAGE_ENGINE=1 \
-DWITH_PERFSCHEMA_STORAGE_ENGINE=1 \
-DWITH_TOKUDB_STORAGE_ENGINE=0 \
-DENABLE_DTRACE=0 \
-DENABLED_LOCAL_INFILE=1 \
-DDEFAULT_CHARSET=utf8mb4 \
-DDEFAULT_COLLATION=utf8mb4_general_ci \
-DEXTRA_CHARSETS=all \
-DMYSQL_USER=mysql \
-DWITH_MEMORY_STORAGE_ENGINE=1 \
-DENABLE_DOWNLOADS=1 \
-DWITH_DEBUG=OFF \
-DENABLED_PROFILING=ON \
-DMYSQL_MAINTAINER_MODE=OFF
scl enable devtoolset-4 bash #在配置前,要先設(shè)置下環(huán)境變量,這樣才能用到 devtoolset-4 套裝里的gcc
make -j4 && make install #-j4 表示開 4 個并發(fā)編譯進程,加速編譯,根據(jù)機器 CPU 核數(shù)調(diào)整,一般是 CPU 核數(shù) + 1
8、編輯配置文件
[client]
port = 3306
socket = /usr/local/mysql/mysql.sock
default-character-set = utf8mb4
[mysql]
prompt="AliSQL [\d]> "
#no-auto-rehash
[mysqld]
port = 3306
user = mysql
skip-name-resolve
socket = /usr/local/mysql/mysql.sock
basedir = /usr/local/mysql
datadir = /usr/local/mysql/data
pid-file = /usr/local/mysql/mysql.pid
tmpdir = /usr/local/mysql/tmp
slave-load-tmpdir = /usr/local/mysql/tmp
log_error = /var/log/mysql/mysqld.log
#secure-file-priv = /usr/local/mysql/uploads
#慢查詢
slow_query_log = 1
long_query_time = 2
log-queries-not-using-indexes
slow_query_log_file = /var/log/mysql/mysql_slow.log
log-slow-admin-statements = 1
log-slow-slave-statements = 1
log-bin-trust-function-creators = 1
#init-connect = 'SET NAMES utf8'
#character-set-server = utf8
init-connect = 'SET NAMES utf8mb4'
character-set-server = utf8mb4
symbolic-links = 0
#lower_case_table_names = 1
performance_schema = 0
#bind-address = 0.0.0.0
#開啟查詢緩存
explicit_defaults_for_timestamp=true
#消耗系統(tǒng)IO 內(nèi)存等
#log-output = FILE
#general_log = off
#general_log_file = /var/log/mysql/general.log
##^^^^^^^^^^^^^^^^^^^^^^主從同步相關(guān)設(shè)置開始^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^##
server-id = 10
binlog_cache_size = 4M
max_binlog_size = 1G
max-binlog-cache-size = 2G
max-relay-log-size = 1G
log_bin = /var/log/mysql/mysql-master-bin
binlog_format = mixed
log_bin_index = /var/log/mysql/bin_log.index
expire_logs_days = 90
#skip-locking
#禁止外網(wǎng)
#skip-networking
#禁止域名解析
skip-name-resolve
#skip-grant-tables
#禁止鎖定
skip-external-locking
skip_show_database
skip_symbolic_links
back_log = 300
max_connections = 1000
max_connect_errors = 6000
open_files_limit = 65535
#表緩存數(shù)
table_open_cache = 128
binlog_cache_size = 1M
#最大表量
max_heap_table_size = 256M
tmp_table_size = 16M
#根據(jù)物理內(nèi)存設(shè)置規(guī)則如下:1G=8 ; 2G=16; 3G=32; 3G>= =64
thread_cache_size = 16
open-files-limit=8192
#排序緩沖
sort_buffer_size=256M
#啟動高速緩存
query_cache_type = 1
#查詢緩存 很少有相同的查詢,最好不要使用查詢緩存
query_cache_size = 128M
query_cache_limit = 2M
flush_time = 0
#連續(xù)緩沖
join_buffer_size = 16M
group_concat_max_len=2048000
table_definition_cache = 1400
ft_min_word_len = 4
#預(yù)讀緩沖
read_buffer_size = 2M
#次緩沖
read_rnd_buffer_size = 64M
query_cache_min_res_unit = 1MB
bulk_insert_buffer_size = 8M
#索引緩沖 比較理想的設(shè)置:Key_blocks_used / (Key_blocks_unused + Key_blocks_used) * 100% ≈ 80%
key_buffer_size=64M
#default-storage-engine = MyISAM
default_storage_engine = InnoDB
innodb_file_per_table = 1
innodb_open_files = 500
#參數(shù)的配置在物理內(nèi)存的70%-80%之間
innodb_buffer_pool_size = 64M
#InnoDB 使用后臺線程處理數(shù)據(jù)頁上寫 I/O(輸入)請求的數(shù)量
innodb_write_io_threads = 4
#InnoDB 使用后臺線程處理數(shù)據(jù)頁上讀 I/O(輸出)請求的數(shù)量
innodb_read_io_threads = 4
innodb_thread_concurrency = 0
innodb_purge_threads = 1
innodb_flush_log_at_trx_commit = 2
#日志緩沖池,控制在8M-16M即可
innodb_log_buffer_size = 2M
#InnoDB 日志文件的大小
innodb_log_file_size = 256M
innodb_log_files_in_group = 3
#控制了 Dirty Page 在 Buffer Pool 中所占的比率
innodb_max_dirty_pages_pct = 90
innodb_lock_wait_timeout = 120
#緩沖區(qū)刷新到磁盤時,刷新臟頁數(shù)量,ssd磁盤,或做了raid后,可將此值設(shè)置較大
innodb_io_capacity = 200
innodb_adaptive_flushing = OFF
innodb_autoextend_increment = 64
innodb_buffer_pool_instances = 8
innodb_concurrency_tickets = 5000
innodb_old_blocks_time = 1000
innodb_stats_on_metadata = 0
myisam_sort_buffer_size = 16M
myisam_max_sort_file_size = 10G
myisam_repair_threads = 1
#導(dǎo)入大的sql文件的方法
interactive_timeout = 28800
wait_timeout = 28800
connect_timeout = 20
#單數(shù)據(jù)包
max_allowed_packet = 500M
#thread_concurrency = 8
[mysqlhotcopy]
interactive-timeout
[mysqldump]
quick
max_allowed_packet = 500M
[myisamchk]
key_buffer_size = 8M
sort_buffer_size = 8M
read_buffer = 4M
write_buffer = 4M
[mysqld_safe]
log_error = /var/log/mysql/mysqld.log
pid-file = /usr/local/mysql/mysql.pid
chown mysql.mysql /etc/my.cnf
chmod 600 /etc/my.cnf
9、初始化數(shù)據(jù)庫:(初始化的時候要注意,會生成一個root的隨機密碼,后面登錄會用到)
chmod 777 scripts/mysql_install_db
scripts/mysql_install_db --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data --user=mysql --defaults-file=/etc/my.cnf
10、設(shè)置環(huán)境變量
vim /etc/profile
export PATH=$PATH:/usr/local/mysql/bin:/usr/local/mysql/lib
11、復(fù)制 mysql 服務(wù)啟動配置文件
cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld
chmod a+x /etc/init.d/mysqld
12、啟動數(shù)據(jù)庫進程
service mysqld start
13、修改root密碼,設(shè)置遠程登錄
mysql -u root
AliSQL [mysql]>use mysql;
AliSQL [mysql]>select host, user from user;
AliSQL [mysql]>update user set password=PASSWORD('rootoo')where user='root';
AliSQL [mysql]>update user set host = '%' where user = 'root'; #授權(quán)遠程登錄用戶名為root,如果報錯,ERROR 1062 (23000): Duplicate entry '%-root' for key 'PRIMARY',不予理會
AliSQL [mysql]>flush privileges;
AliSQL [mysql]>grant all on . to "root"@"172.30.41.72" identified by "123456"; #授權(quán)172.30.41.72以root用戶遠程登錄訪問數(shù)據(jù)庫,root密碼為123456
AliSQL [mysql]>grant all on . to "root"@"%" identified by "123456"; #授權(quán)所有ip都可以以root用戶遠程登錄訪問數(shù)據(jù)庫,root密碼為123456
AliSQL [mysql]>grant all on . to "root"@"localhost" identified by "123456"; #授權(quán)l(xiāng)ocalhost以root用戶遠程登錄訪問數(shù)據(jù)庫,root密碼為123456
AliSQL [mysql]>select user from user; #查看所有用戶
14、重啟mysql
service mysqld restart
chkconfig mysqld on
15、下載phpMyAdmin
wget https://files.phpmyadmin.net/phpMyAdmin/4.7.0/phpMyAdmin-4.7.0-all-languages.zip
16、解壓phpMyAdmin-4.7.0-all-languages.zip
unzip phpMyAdmin-4.7.0-all-languages.zip
17、打開libraries下的config.default.php文件,依次找到下面各項,按照說明配置即可:
a.訪問網(wǎng)址
$cfg['pmaabsoluteuri'] = '192.168.1.5';這里填寫phpmyadmin的訪問網(wǎng)址
b.mysql主機信息
$cfg['servers'][$i]['host'] = 'localhost'; // mysql hostname or ip address
填寫localhost或mysql所在 mysql端口,如果是默認3306,保留為空即可 c.mysql用戶名和密碼 $cfg['servers'][$i]['user'] = 'root'; // mysql user訪問phpmyadmin使用的mysql用戶名 fg['servers'][$i]['password'] = 'rootoo'; // mysql password (only needed對應(yīng)上述mysql用戶名的密碼 $cfg['servers'][$i]['auth_type'] = 'http'; 在此有四種模式可供選擇,cookie,http,http,config config方式即輸入phpmyadmin的訪問網(wǎng)址即可直接進入,無需輸入用戶名和密碼,是不安全的,不推薦使用。 當(dāng)該項設(shè)置為cookie,http或http時,登錄phpmyadmin需要數(shù)據(jù)用戶名和密碼進行驗證,,具體如下: php安裝模式為nginx/apache,可以使用http和cookie; php安裝模式為cgi,可以使用cookie e.短語密碼(blowfish_secret)的設(shè)置 $cfg['blowfish_secret'] = ''; 如果認證方法設(shè)置為cookie,就需要設(shè)置短語密碼,但是不能留空,否則會在登錄phpmyadmin時提示錯誤 f.配置 1、打開 /libraries/config.default.php文件(舊版本是根目錄下的config.inc.php文件),用寫字板(不要用記事本,這是utf8編碼)進行編輯,按照說明配置即可。 2、查找 $cfg['pmaabsoluteuri']=‘'; // 修改為你將上傳到空間的phpmyadmin的網(wǎng)址 如:$cfg['pmaabsoluteuri'] =‘http: // 網(wǎng)站域名/phpmyadmin/'; 3、查找 $cfg['servers'][$i]['host'] =‘localhost'; // 通常用默認,也有例外,可以不用修改 4、查找 $cfg['servers'][$i]['auth_type'] =‘config'; // 在自己的機子里調(diào)試用config;如果在網(wǎng)絡(luò)上的空間用cookie. 18、http://192.168.1.5/phpMyAdmin/ 輸入用戶名root密碼rootoo后,訪問正常 常見的錯誤:#2002 - Permission denied — 服務(wù)器沒有響應(yīng)(或本地服務(wù)器的套接字沒有正確設(shè)置)。
網(wǎng)站標(biāo)題:AliSQL-5.6.32編譯安裝
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供品牌網(wǎng)站制作、網(wǎng)站制作、搜索引擎優(yōu)化、網(wǎng)站內(nèi)鏈、建站公司、全網(wǎng)營銷推廣
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源:
創(chuàng)新互聯(lián)
d.認證方法
報錯原因:如果未指定指定主機名或指定了特殊的主機名localhost,將使用Unix套接字。
Unix套接字默認為/tmp/mysql.sock,如果沒有配置這樣的套接字文件或者配置不正確,所以自然是連接失敗了。
解決方法:$cfg['servers'][$i]['host'] =‘localhost';改為$cfg['servers'][$i]['host'] =‘127.0.0.1';
轉(zhuǎn)載來于:http://chinadenli.net/article16/ihoodg.html