centos7.2离线安装mysql5.7.18.tar.gz

这篇文章主要为大家详细介绍了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.创建用户和相应文件夹:

?

1

2

3

4

5

6

7

8

9

10

# 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.安装

?

1

2

3

4

5

6

7

8

9

10

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(可以不做)

?

1

2

3

4

5

6

# 依据情况修改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.修改默认密码:

?

1

2

3

4

5

6

/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.防火墙、赋权(按需做)

?

1

2

3

4

5

6

7

8

9

# 防火墙

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.本地隐藏密码登录(可以不做)

?

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

## 使用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解析

?

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

46

47

48

49

50

51

52

53

54

55

56

57

58

59

60

61

62

63

64

65

66

67

68

69

70

71

72

73

74

75

[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'

以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持钦钦技术栈。

原文链接:https://blog.csdn.net/basicworld/article/details/83713925

版权声明:本文(即:原文链接:https://www.qin1qin.com/catagory/15913/)内容由互联网用户自发投稿贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件至 630367839@qq.com 举报,一经查实,本站将立刻删除。

(0)
上一篇 2022年 8月 27日 2:53:13
下一篇 2022年 8月 27日 2:53:20

软件定制开发公司

相关阅读

发表回复

登录后才能评论
通知:禁止投稿所有关于虚拟货币,币圈类相关文章,发现立即永久封锁账户ID!