七仔的博客

七仔的博客GithubPages分博

0%

centos7.5安装mysql8

用centos7.5服务器安装myql8踩了挺多坑,记录一下,千万不要用yum在centos7.5安装mysql8

centos7.5安装mysql8

之前装的是个mysql5.7,但是挪数据什么的太麻烦了,就想装个mysql8,一般网上安装都是用yum安装,但我的用yum安装5.7很快,8就是装不上,一直报错,最后采用了另一种方法,参考了centos7.6 上mysql8.0的安装,有修改

下载mysql

1
wget https://mirrors.tuna.tsinghua.edu.cn/mysql/downloads/MySQL-8.0/mysql-8.0.17-linux-glibc2.12-x86_64.tar.xz

进行解压和移动解压文件位置

1
2
tar xf mysql-8.0.17-linux-glibc2.12-x86_64.tar.xz
mv mysql-8.0.17-linux-glibc2.12-x86_64 /usr/local/mysql

建立目录并赋予权限

1
2
3
cd /usr/local/mysql
mkdir data sql_log undo_log
chown mysql:root -R data/ sql_log/ undo_log/

添加msyql路径到path

1
export PATH=$PATH:/usr/localmysql/bin
1
source /etc/profile

写入my.cnf,放在最下方

1
vim /etc/my.cnf

初始化mysql

1
mysqld --initialize --user=root --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data

拷贝启动程序

1
2
cd /usr/local/mysql/support-files
cp mysql.server /etc/init.d/mysqld

查询密码,一般最后的乱码就是密码

1
grep password mysql-error.log

登录mysql,然后输入刚才查到的密码

1
mysql -uroot -p

my.cnf文件

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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
[client]
port=3306
socket=/usr/local/mysql/data/mysql.sock
[mysqld]
# Skip #
skip_name_resolve= 1
skip-external-locking=1
symbolic-links= 0
# GENERAL #
user = mysql
default_storage_engine=InnoDB
character-set-server=utf8
socket=/usr/local/mysql/data/mysql.sock
pid_file=/usr/local/mysql/data/mysqld.pid
basedir = /usr/local/mysql
#log_error=/usr/local/mysql/sql_log/mysql_1302.err
port=3306
bind-address=0.0.0.0
explicit_defaults_for_timestamp=on
#sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
sql_mode=NO_ENGINE_SUBSTITUTION
#read_only=on
# MyISAM #
key_buffer_size=32M
#myisam_recover=FORCE,BACKUP

# undo log #
innodb_undo_directory=/usr/local/mysql/undo_log
innodb_undo_tablespaces=16

# SAFETY #
max_allowed_packet=100M
max_connect_errors=1000000
sysdate_is_now=1
#innodb = FORCE
#innodb_strict_mode=1
secure-file-priv=/usr/local/mysql/sql_log
default_authentication_plugin='mysql_native_password'
# Replice #
server-id=1306
relay_log=mysqld-relay-bin
gtid_mode=on
enforce-gtid-consistency
log-slave-updates=on
master_info_repository=TABLE
relay_log_info_repository=TABLE


# group replication specific options
#plugin-load=group_replication.so
#group_replication=FORCE_PLUS_PERMANENT
#transaction-write-set-extraction=XXHASH64
#loose-group_replication_start_on_boot=ON
#loose-group_replication_bootstrap_group=OFF
#loose-group_replication_group_name='aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa'
#group_replication_local_address='10.102.13.2:33061'
#group_replication_group_seeds='10.102.13.3:33061,10.102.13.5:33061'

# DATA STORAGE #
datadir=/usr/local/mysql/data/
tmpdir=/tmp

# BINARY LOGGING #
log_bin=/usr/local/mysql/sql_log/mysql-bin
max_binlog_size=1000M
binlog_format=row
expire_logs_days=7
# sync_binlog=1

# CACHES AND LIMITS #
tmp_table_size = 32M
max_heap_table_size = 32M
max_connections = 4000
thread_cache_size = 2048
open_files_limit = 65535
table_definition_cache = 4096
table_open_cache = 4096
sort_buffer_size = 2M
read_buffer_size = 2M
read_rnd_buffer_size = 2M
# thread_concurrency = 24
join_buffer_size = 1M
# table_cache = 32768
thread_stack = 512k
max_length_for_sort_data = 16k


# INNODB #
innodb_flush_method = O_DIRECT
innodb_log_buffer_size = 16M
innodb_flush_log_at_trx_commit = 2
innodb_file_per_table = 1
innodb_buffer_pool_size = 2G
#innodb_buffer_pool_instances = 8
innodb_stats_on_metadata = off
innodb_open_files = 8192
innodb_read_io_threads = 16
innodb_write_io_threads = 16
innodb_io_capacity = 20000
innodb_thread_concurrency = 0
innodb_lock_wait_timeout = 60
innodb_old_blocks_time=1000
innodb_use_native_aio = 1
innodb_purge_threads=1
innodb_change_buffering=all
innodb_log_file_size = 128M
innodb_log_files_in_group = 3
innodb_data_file_path = ibdata1:1024M:autoextend

innodb_rollback_on_timeout=on
# LOGGING #
log_error=/usr/local/mysql/sql_log/mysql-error.log
# log_queries_not_using_indexes = 1
# slow_query_log = 1
slow_query_log_file=/usr/local/mysql/sql_log/slowlog_1305.log

# TimeOut #
#interactive_timeout = 30
#wait_timeout = 30
#net_read_timeout = 60

[mysqldump]
quick
max_allowed_packet = 100M

[mysql]
no-auto-rehash
# Remove the next comment character if you are not familiar with SQL
#safe-updates

[myisamchk]
key_buffer_size = 256M
sort_buffer_size = 256M
read_buffer = 2M
write_buffer = 2M

[mysqlhotcopy]
interactive-timeout

此为博主副博客,留言请去主博客,转载请注明出处:https://www.baby7blog.com/myBlog/62.html

欢迎关注我的其它发布渠道