mysql 8.0.11 安装二进制_MYSQL8.0.11二进制安装

Mysql8.0源码编译安装涉及包较多,推荐现在二进制包安装。

一、创建用户和组

groupadd mysql

useradd -g mysql mysql

echo "password" | passwd --stdin mysql

二、创建目录

mkdir -p /data/mysql/tmp

mkdir -p/data/mysql/data

mkdir -p/data/mysql/dumps

mkdir -p /data/mysql/log

mkdir -p /data/mysql/undo

mkdir -p /data/servers/mysql/etc

chown mysql.mysql -R /data/mysql

chown mysql.mysql -R /data/servers/mysql

三、下载二进制包

https://cdn.mysql.com//Downloads/MySQL-8.0/mysql-8.0.11-linux-glibc2.12-x86_64.tar.gz

四、解压到指定目录

tar -zxvf/root/mysql-8.0.11-linux-glibc2.12-x86_64.tar.gz -C /data/servers/mysql

五、添加环境变量

sed -i '$a export PATH=$PATH:/data/servers/mysql/bin'/etc/profile; source /etc/profile

六、创建error.log(8.0版本在无error.log的情况下不会自动创建,会报错)

touch /data/mysql/log/error.log

chown mysql.mysql /data/mysql/log/error.log

七、初始化库表结构

mysqld --initialize --user=mysql --basedir=/data/servers/mysql/ --datadir=/data/mysql/data --innodb_undo_directory=/data/mysql/undo --innodb_undo_tablespaces=4 --socket=/data/mysql/tmp/mysql.socket --port=3358 --innodb_data_file_path=ibdata1:512M:autoextend --lower-case-table-names=1

注意8.0初始化必须指定这些参数,不然会报错

2018-07-04T07:54:21.696764Z 1 [ERROR]  [MY-012930] [InnoDB] InnoDB: Plugin initialization aborted with error Generic  error.

2018-07-04T07:54:22.297200Z 1 [ERROR] [MY-010334] [Server] Failed to  initialize DD Storage Engine

2018-07-04T07:54:22.297359Z 0 [ERROR] [MY-010020] [Server] Data Dictionary  initialization failed.

2018-07-04T07:54:22.297381Z 0 [ERROR] [MY-010119] [Server] Aborting

初始化产生的初始密码:

[Note] [MY-010454] [Server] A temporary password is generated for root@localhost:Jod6BHNlkd*8

八、添加配置文件(仅供参考)

vim /data/servers/mysql/etc/my.cnf

[client]

port

3358

socket

/data/mysql/tmp/mysql.socket

[mysqld]

innodb_undo_tablespaces

4

innodb_undo_directory

/data/mysql/undo

######MySQL8.0自适应参数######

#innodb_log_file_size

1363148800

innodb_data_file_path

ibdata1:512M:autoextend

innodb_checksum_algorithm

crc32

explicit_defaults_for_timestamp

ON

innodb_buffer_pool_load_at_startup

ON

innodb_buffer_pool_dump_at_shutdown

ON

read_only

0

port

3358

socket

/data/mysql/tmp/mysql.socket

datadir

/data/mysql/data

basedir

/data/servers/mysql

user

mysql

innodb_dedicated_server

1

#---GLOBAL---#

#transaction-isolation

READ-COMMITTED

sql_mode

NO_ENGINE_SUBSTITUTION

default_authentication_plugin

mysql_native_password

######在MySQL8.0中注释掉此参数,不然就会有警告信息######

#secure_file_priv

default-storage-engine

INNODB

character-set-server

utf8mb4

######mysql8.0要求设定为0######

lower_case_table_names

1

log-error

/data/mysql/log/error.log

general_log

0

general_log_file

/data/mysql/log/general.log

pid-file

/data/mysql/data/mysql.pid

slow-query-log

slow_query_log_file

/data/mysql/log/slow.log

tmpdir

/data/mysql/tmp

long_query_time

0.1

#enableslaveslowlog

log_slow_slave_statements

1

thread_cache_size

512

table_open_cache

16384

table_definition_cache

16384

table_open_cache_instances

8

######弃用######

#metadata_locks_hash_instances

256

sort_buffer_size

256K

join_buffer_size

256K

read_buffer_size

256K

read_rnd_buffer_size

256K

key_buffer_size

64M

myisam_sort_buffer_size

64M

tmp_table_size

16M

max_heap_table_size

16M

open_files_limit

65535

######mysql8.0无此参数######

#query_cache_size

0

######mysql8.0无此参数######

#query_cache_type

0

log_bin_trust_function_creators

1

#---NETWORK---#

back_log

2000

max_allowed_packet

64M

interactive_timeout

28800

wait_timeout

28800

max-connections

2000

#skip-name-resolve

#---REPL---#

server-id

1234567

report_host

192.168.1.1

#nogtidconfig

log-bin

mysql-bin

binlog_format

row

binlog_row_image

full

######弃用######

#expire_logs_days

7

binlog_expire_logs_seconds

604800

relay-log

relay-log

log_slave_updates

slave_net_timeout

30

skip-slave-start

slave-parallel-workers

0

relay_log_info_repository

TABLE

master_info_repository

TABLE

sync_master_info

0

sync_relay_log_info

0

sync_binlog

1

#flushdisk

sync_relay_log

0

slave_rows_search_algorithms

INDEX_SCAN,HASH_SCAN

#rpl_semi_sync_master_enabled

1

#rpl_semi_sync_slave_enabled

1

#rpl_semi_sync_master_timeout

1000

relay_log_recovery

1

#---INNODB---#

innodb_adaptive_flushing

ON

innodb_adaptive_flushing_lwm

15

innodb_flushing_avg_loops

30

innodb_adaptive_hash_index

ON

innodb_data_home_dir

/data/mysql/data

innodb_file_per_table

ON

innodb_log_group_home_dir

/data/mysql/data

innodb_log_files_in_group

3

innodb_log_buffer_size

32M

innodb_flush_log_at_trx_commit

1

innodb_flush_log_at_timeout

1

innodb_lock_wait_timeout

30

######MySQL8.0自适应参数######

#innodb_flush_method

O_DIRECT

innodb_max_dirty_pages_pct

75

innodb_max_dirty_pages_pct_lwm

0

######MySQL8.0自适应参数######

#innodb_buffer_pool_size

100G

innodb_buffer_pool_instances

8

innodb_change_buffering

all

innodb_change_buffer_max_size

10

innodb_autoextend_increment

64

innodb_thread_concurrency

32

innodb_spin_wait_delay

6

innodb_sync_spin_loops

30

innodb_open_files

65535

innodb_old_blocks_time

30

innodb_online_alter_log_max_size

512M

innodb_write_io_threads

8

innodb_read_io_threads

8

innodb_flush_neighbors

0

innodb_io_capacity

3000

innodb_io_capacity_max

16000

innodb_lru_scan_depth

1024

innodb_purge_threads

4

innodb_purge_batch_size

400

######mysql8.0无此参数######

#innodb_file_format

Barracuda

######mysql8.0无此参数######

#innodb_large_prefix

ON

##innodb_force_load_corrupted

OFF

#innodb_force_recovery

0

#bufferpooldumpandload

innodb_buffer_pool_filename

ib_buffer_pool

innodb_buffer_pool_load_abort

OFF

innodb_buffer_pool_dump_now

OFF

innodb_buffer_pool_load_now

OFF

[mysqldump]

quick

max_allowed_packet

64M

[mysql]

no-auto-rehash

default-character-set

utf8mb4

prompt

(\u@\h)[\d]>

[myisamchk]

key_buffer_size

128M

sort_buffer_size

128M

read_buffer

2M

write_buffer

2M

[mysqlhotcopy]

interactive-timeout

chown mysql.mysql -R /data/servers/mysql

九、启动

/data/servers/mysql/bin/mysqld_safe --defaults-file=/servers/mysql/etc/my.cnf &

十、登录(初始密码)

/data/servers/mysql/bin/mysql -uroot -p --socket=/data/mysql/tmp/mysql.socket

十一、修改密码

mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY "123456";(默认采用新加密方式)

注意8.0 默认采用新的加密方式:caching_sha2_password,会导致8.0以下版本的客户端连接不上:

ERROR 2059 (HY000): Authentication plugin 'caching_sha2_password' cannot be loaded: /datatt/servers/mysql/lib/plugin/caching_sha2_password.so: cannot open shared  object file: No such file or directory

解决:修改为老的加密方式:mysql_native_password

mysql> ALTER USER `test`@`%` IDENTIFIED WITH mysql_native_password BY "123456"; #修改加密规则

mysql> ALTER USER `test`@`%` IDENTIFIED BY "123456" PASSWORD EXPIRE NEVER; #永不过期

mysql> FLUSH PRIVILEGES; #刷新权限

或者在配置文件my.cnf修改参数采用老的加密方式

default_authentication_plugin = mysql_native_password

接下来可以自由发挥了~~~

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值