這篇文章給大家介紹linux下MySQL5.5&mysql5.6的tar該怎么搭建,內(nèi)容非常詳細(xì),感興趣的小伙伴們可以參考借鑒,希望對大家能有所幫助。
創(chuàng)新互聯(lián)主營大安網(wǎng)站建設(shè)的網(wǎng)絡(luò)公司,主營網(wǎng)站建設(shè)方案,重慶App定制開發(fā),大安h5重慶小程序開發(fā)公司搭建,大安網(wǎng)站營銷推廣歡迎大安等地區(qū)企業(yè)咨詢
提前yum安裝依賴包
yum -y install perl perl-devel libaio* 'perl(Data::Dumper)'
準(zhǔn)備好mysql的tar包
1、在/usr/local下解壓mysql的安裝包,并將解壓后的文件改名為mysql,其執(zhí)行命令
tar zxvf mysql-5.6.16-linux-glibc2.5-x86_64.tar 解壓
mv mysql-5.6.16-linux-glibc2.5-x86_64 mysql 改名
2、建立mysql用戶,并賦予/usr/local/mysql目錄的權(quán)限
useradd mysql 建用戶
chown mysql:mysql -R mysql 賦權(quán)
3、建立數(shù)據(jù)目錄,并把目錄賦權(quán)給mysql用戶
mkdir -p /data/mysql 建數(shù)據(jù)目錄
chown mysql:mysql -R /data 賦權(quán)
查看賦權(quán)是否成功,可在其目錄上以及l(fā)l查看所屬用戶及權(quán)限
4、配置文件
在/etc目錄下新建my.cnf文件,并編輯配置文件
vim /etc/my.cnf 創(chuàng)建并編輯配置文件,寫入以下內(nèi)容
注意:以下配置中適合主庫,若要對從庫使用,需要注釋配置中的事件event_scheduler = 1
[client] port = 3306 socket = /data/mysql/mysql.sock #default-character-set=utf8 [mysql] prompt = "mysql [\d]>\_" #default-character-set=utf8 [mysqld] port = 3306 socket = /data/mysql/mysql.sock basedir = /usr/local/mysql datadir = /data/mysql open_files_limit = 3072 back_log = 103 max_connections = 512 max_connect_errors = 100000 table_open_cache = 512 external-locking = FALSE max_allowed_packet = 32M sort_buffer_size = 2M join_buffer_size = 2M thread_cache_size = 51 query_cache_size = 32M tmp_table_size = 96M max_heap_table_size = 96M slow_query_log = 1 slow_query_log_file = /data/mysql/slow.log log-error = /data/mysql/error.log long_query_time = 2 event_scheduler = 1 lower_case_table_names = 1 log-bin-trust-function-creators=1 server-id = 1 log-bin = /data/mysql/mysql-bin sync_binlog = 1 binlog_cache_size = 4M max_binlog_cache_size = 8M max_binlog_size = 1024M expire_logs_days = 7 key_buffer_size = 32M read_buffer_size = 1M read_rnd_buffer_size = 16M bulk_insert_buffer_size = 64M character-set-server=utf8 default-storage-engine = InnoDB binlog_format=row #gtid_mode=on #log_slave_updates=1 #enforce_gtid_consistency=1 transaction_isolation = REPEATABLE-READ innodb_additional_mem_pool_size = 16M innodb_buffer_pool_size = 1434M innodb_data_file_path = ibdata1:1024M:autoextend innodb_flush_log_at_trx_commit = 1 innodb_log_buffer_size = 16M innodb_log_file_size = 256M innodb_log_files_in_group = 2 innodb_max_dirty_pages_pct = 50 innodb_file_per_table = 1 innodb_locks_unsafe_for_binlog = 0 [mysqldump] quick max_allowed_packet = 32M
5、初始化數(shù)據(jù)庫
/usr/local/mysql/scripts/mysql_install_db --defaults-file=/etc/my.cnf --basedir=/usr/local/mysql --datadir=/data/mysql/ --user=mysql
初始化報錯: [root@localhost data]# /usr/local/mysql/scripts/mysql_install_db --defaults-file=/etc/my.cnf --datadir=/data/mysql/ --basedir=/usr/local/mysql --user=mysql Can't locate Data/Dumper.pm in @INC (@INC contains: /usr/local/lib64/perl5 /usr/local/share/perl5 /usr/lib64/perl5/vendor_perl /usr/share/perl5/vendor_perl /usr/lib64/perl5 /usr/share/perl5 .) at /usr/local/mysql/scripts/mysql_install_db line 42. BEGIN failed--compilation aborted at /usr/local/mysql/scripts/mysql_install_db line 42. 解決: yum install 'perl(Data::Dumper)'
6、啟動數(shù)據(jù)庫
/bin/mysqld_safe --defaults-file=/etc/my.cnf &
或者通過cp數(shù)據(jù)庫啟動腳本
cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld
chmod +x /etc/init.d/mysqld
啟動: /etc/init.d/mysqld start
關(guān)閉: /etc/init.d/mysqld stop
7、加入到開機(jī)自啟
chkconfig --add mysqld
chkconfig --list mysqld 查看mysql的開啟等級
chkconfig --level 0 mysqld on
8、注意配置環(huán)境變量
9、從庫配置,請加上如下參數(shù),記得注意主從的server_id不能相同
log_slave_updates=1 relay-log=/data/mysql/relay-log-bin relay-log-index=/data/mysql/slave-relay-bin.index max_relay_log_size=300M #關(guān)閉自動刪除relay-log relay_log_purge=0
關(guān)于linux下mysql5.5&mysql5.6的tar該怎么搭建就分享到這里了,希望以上內(nèi)容可以對大家有一定的幫助,可以學(xué)到更多知識。如果覺得文章不錯,可以把它分享出去讓更多的人看到。
本文標(biāo)題:linux下mysql5.5&mysql5.6的tar該怎么搭建
網(wǎng)頁網(wǎng)址:http://jinyejixie.com/article24/iicjje.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供手機(jī)網(wǎng)站建設(shè)、動態(tài)網(wǎng)站、品牌網(wǎng)站制作、營銷型網(wǎng)站建設(shè)、域名注冊、面包屑導(dǎo)航
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)