您好,登錄后才能下訂單哦!
這篇文章給大家介紹linux下mysql5.5&mysql5.6的tar該怎么搭建,內容非常詳細,感興趣的小伙伴們可以參考借鑒,希望對大家能有所幫助。
提前yum安裝依賴包
yum -y install perl perl-devel libaio* 'perl(Data::Dumper)'
準備好mysql的tar包
1、在/usr/local下解壓mysql的安裝包,并將解壓后的文件改名為mysql,其執行命令
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目錄的權限
useradd mysql 建用戶
chown mysql:mysql -R mysql 賦權
3、建立數據目錄,并把目錄賦權給mysql用戶
mkdir -p /data/mysql 建數據目錄
chown mysql:mysql -R /data 賦權
查看賦權是否成功,可在其目錄上以及ll查看所屬用戶及權限
4、配置文件
在/etc目錄下新建my.cnf文件,并編輯配置文件
vim /etc/my.cnf 創建并編輯配置文件,寫入以下內容
注意:以下配置中適合主庫,若要對從庫使用,需要注釋配置中的事件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、初始化數據庫
/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、啟動數據庫
/bin/mysqld_safe --defaults-file=/etc/my.cnf &
或者通過cp數據庫啟動腳本
cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld
chmod +x /etc/init.d/mysqld
啟動: /etc/init.d/mysqld start
關閉: /etc/init.d/mysqld stop
7、加入到開機自啟
chkconfig --add mysqld
chkconfig --list mysqld 查看mysql的開啟等級
chkconfig --level 0 mysqld on
8、注意配置環境變量
9、從庫配置,請加上如下參數,記得注意主從的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 #關閉自動刪除relay-log relay_log_purge=0
關于linux下mysql5.5&mysql5.6的tar該怎么搭建就分享到這里了,希望以上內容可以對大家有一定的幫助,可以學到更多知識。如果覺得文章不錯,可以把它分享出去讓更多的人看到。
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。