时间:2021-05-25
因为网络隔离,无法使用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.创建用户和相应文件夹:
4.安装
cd /tmptar zxvf mysql-5.7.18-linux-glibc2.5-x86_64.tar.gzmv mysql-5.7.18-linux-glibc2.5-x86_64 mysqlmv mysql /apps/mysqlcp 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.servercp support-files/mysql.server /etc/init.d/mysqlsystemctl start mysql.service# 添加开机启动chkconfig mysql.server on6.启动数据库/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 -p8.防火墙、赋权(按需做)
# 防火墙firewall-cmd --zone=public --add-port=7006/tcp --permanentsystemctl restart firewalldfirewall-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=7006default-character-set=utf8[mysqld]skip-name-resolvesecure_file_priv="/"character-set-server=utf8user=mysqlserver_id=20180917port=7006socket=/data/mysql7006/mysql.sockpid-file=/data/mysql7006/mysql.pidbasedir=/apps/mysqldatadir=/data/mysql7006/datalog-error=/logs/mysql7006/error-loglog-bin=/logs/mysql7006/bin-logmax_allowed_packet = 64Mdefault_storage_engine = InnoDBinnodb_strict_mode = 1innodb_buffer_pool_size = 5Ginnodb_stats_on_metadata = 0innodb_file_format = Barracudainnodb_flush_method = O_DIRECTinnodb_log_files_in_group = 2innodb_log_file_size = 4Ginnodb_log_buffer_size = 128Minnodb_file_per_table = 1innodb_max_dirty_pages_pct = 60innodb_io_capacity = 4000lower_case_table_names = 1#ADD INNODBinnodb_buffer_pool_instances = 16innodb_flush_log_at_trx_commit = 1innodb_adaptive_flushing = 1innodb_thread_concurrency = 0innodb_stats_persistent = 1innodb_purge_threads = 4innodb_use_native_aio = 1##innodb_use_sys_malloc = 1innodb_autoinc_lock_mode = 2innodb_change_buffering = insertsinnodb_read_io_threads = 16innodb_write_io_threads = 16expire_logs_days = 30# CACHES AND LIMITS #key_buffer_size = 32Mtmp_table_size = 256Mmax_heap_table_size = 256Mtable_open_cache = 4096query_cache_type = 0query_cache_size = 0max_connections = 2000thread_cache_size = 1024open_files_limit = 65535#ADD OTHERSmetadata_locks_hash_instances = 256table_open_cache_instances = 16back_log = 1500wait_timeout = 3600interactive_timeout = 3600master_info_repository=TABLErelay_log_info_repository=TABLElog_slave_updates=ONbinlog_checksum=NONEbinlog_format=ROWtransaction_isolation=READ-COMMITTEDsql_mode='STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION'以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持。
声明:本页内容来源网络,仅供用户参考;我单位不保证亦不表示资料全面及准确无误,也不保证亦不表示这些资料为最新信息,如因任何原因,本网内容或者用户因倚赖本网内容造成任何损失或损害,我单位将不会负任何法律责任。如涉及版权问题,请提交至online#300.cn邮箱联系删除。
最新在学习MySQL,纯新手,对Linux了解的也不多,因为是下载的最新版的MySQL(MySQL5.7.18)二进制包,CentOS7.2下测试安装,方便以后
一、准备工作 1.下载并安装centos7.2,配置好网络环境,确保centos能上网,可以获取到yum源。 centos7.2的下载地址:http://
系统环境:vm12下的centos7.2当前安装版本:elasticsearch-2.4.0.tar.gzJava操作es集群步骤1:配置集群对象信息;2:创建
安装说明安装环境:CentOS-6.3安装方式:源码编译安装软件:httpd-2.2.6.tar.gz|pcre-8.32.tar.gz|apr-1.4.6.t
一、安装要求安装环境:CentOS-6.5-32bit软件名称:mysql-cluster-gpl-7.2.25-linux2.6-i686.tar.gz下载地