您好,登錄后才能下訂單哦!
這篇文章給大家分享的是有關centos7.2如何離線安裝mysql5.7.18.tar.gz的內容。小編覺得挺實用的,因此分享給大家做個參考,一起跟隨小編過來看看吧。
因為網絡隔離,無法使用yum方式安裝mysql,這里介紹linux服務器上手動離線安裝mysql的方法。
目的
離線安裝mysql服務
服務器:centos7.2,配置本地yum源
mysql版本:mysql5.7.18
步驟
1.下載安裝包mysql-5.7.18-linux-glibc2.5-x86_64.tar.gz,安裝包傳輸到目的服務器/tmp目錄
2.my.cnf文件(見文末)傳輸到目的服務器的/tmp目錄
3.創建用戶和相應文件夾:
# prepare groupadd mysql useradd -r -g mysql -s /bin/false mysql yum install -y autoconf mkdir /apps mkdir /logs mkdir /data mkdir -p /data/mysql7006/data && chown -R mysql:mysql /data/mysql7006 mkdir /logs/mysql7006 && chown -R mysql:mysql /logs/mysql7006 touch /logs/mysql7006/error-log.err && chown -R mysql:mysql /logs/mysql7006/error-log.err
4.安裝
cd /tmp tar zxvf mysql-5.7.18-linux-glibc2.5-x86_64.tar.gz mv mysql-5.7.18-linux-glibc2.5-x86_64 mysql mv mysql /apps/mysql cp my.cnf /apps/mysql/ chown -R mysql:mysql /apps/mysql/ # 初始化數據庫, cd /apps/mysql ./bin/mysqld --initialize --user=mysql --basedir=/apps/mysql/ --datadir=/data/mysql7006/data/
初始化過程中會生成一個默認密碼記得記下來,后續修改用。
5.注冊service(可以不做)
# 依據情況修改support-files/mysql.server cp support-files/mysql.server /etc/init.d/mysql systemctl start mysql.service # 添加開機啟動 chkconfig mysql.server on
6.啟動數據庫/apps/mysql/bin/mysqld_safe --defaults-file=/apps/mysql/my.cnf &
7.修改默認密碼:
/apps/mysql/bin/mysqladmin -u root password 'password' --port=7006 --socket=/data/mysql7006/mysql.sock -p # 修改后清空linux的history記錄 history -c # 登陸測試: /apps/mysql/bin/mysql -u root --port=7006 --socket=/data/mysql7006/mysql.sock -p
8.防火墻、賦權(按需做)
# 防火墻 firewall-cmd --zone=public --add-port=7006/tcp --permanent systemctl restart firewalld firewall-cmd --zone=public --query-port=7006/tcp # 賦權給登陸用戶 use mysql; grant all privileges on *.* to user@'ip' identified by "password"; flush privileges; select host,user,password from user;
9.本地隱藏密碼登錄(可以不做)
## 使用mysql_config_editor 制作登錄文件 /apps/mysql/bin/mysql_config_editor set --login-path=root_pass --user=root --port=7006 --socket=/data/mysql7006/mysql.sock --password ## 輸入密碼:****** ## 文件會加密存儲于用戶根目錄下.mylogin.cnf /apps/mysql/bin/mysql_config_editor print --all ## 下次登錄時直接敲: /apps/mysql/bin/mysql --login-path=root_pass # 再省事一些:set alias # 打開file .bashrc,添加 alias db7006='/apps/mysql/bin/mysql --login-path=root_pass' # 然后退出執行: source .bashrc ## 下次登錄時直接敲: db7006
附錄
my.cnf文件
主要功能:全局utf8字符集、自定義端口、數據文件夾、日志文件夾、默認引擎innodb(支持事務,對xtrabackup友好)、跳過客戶端登陸時的dns解析
[client] port=7006 default-character-set=utf8 [mysqld] skip-name-resolve secure_file_priv="/" character-set-server=utf8 user=mysql server_id=20180917 port=7006 socket=/data/mysql7006/mysql.sock pid-file=/data/mysql7006/mysql.pid basedir=/apps/mysql datadir=/data/mysql7006/data log-error=/logs/mysql7006/error-log log-bin=/logs/mysql7006/bin-log max_allowed_packet = 64M default_storage_engine = InnoDB innodb_strict_mode = 1 innodb_buffer_pool_size = 5G innodb_stats_on_metadata = 0 innodb_file_format = Barracuda innodb_flush_method = O_DIRECT innodb_log_files_in_group = 2 innodb_log_file_size = 4G innodb_log_buffer_size = 128M innodb_file_per_table = 1 innodb_max_dirty_pages_pct = 60 innodb_io_capacity = 4000 lower_case_table_names = 1 #ADD INNODB innodb_buffer_pool_instances = 16 innodb_flush_log_at_trx_commit = 1 innodb_adaptive_flushing = 1 innodb_thread_concurrency = 0 innodb_stats_persistent = 1 innodb_purge_threads = 4 innodb_use_native_aio = 1 ##innodb_use_sys_malloc = 1 innodb_autoinc_lock_mode = 2 innodb_change_buffering = inserts innodb_read_io_threads = 16 innodb_write_io_threads = 16 expire_logs_days = 30 # CACHES AND LIMITS # key_buffer_size = 32M tmp_table_size = 256M max_heap_table_size = 256M table_open_cache = 4096 query_cache_type = 0 query_cache_size = 0 max_connections = 2000 thread_cache_size = 1024 open_files_limit = 65535 #ADD OTHERS metadata_locks_hash_instances = 256 table_open_cache_instances = 16 back_log = 1500 wait_timeout = 3600 interactive_timeout = 3600 master_info_repository=TABLE relay_log_info_repository=TABLE log_slave_updates=ON binlog_checksum=NONE binlog_format=ROW transaction_isolation=READ-COMMITTED sql_mode='STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION'
感謝各位的閱讀!關于“centos7.2如何離線安裝mysql5.7.18.tar.gz”這篇文章就分享到這里了,希望以上內容可以對大家有一定的幫助,讓大家可以學到更多知識,如果覺得文章不錯,可以把它分享出去讓更多的人看到吧!
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。