Windows平台上使用noinstall方式部署MySQL 8.0

1、之前本博写过一篇在windows下面使用uninstall方式安装MySQL 5.7.9的文章,随着MySQL 8.0 GA版本的发布,预示着8.0作为一个生产环境版本正式走上舞台,有必要将之前的安装方法予以更新,以飨读者。(其实还是用MariaDB开源社区解决方案多)

2、安装平台

Microsoft Windows Server 2016 Standard

MySQL 8.0.11 noinstall archive

3、下载安装包

https://cdn.mysql.com//Downloads/MySQL-8.0/mysql-8.0.11-winx64.zip

4、安装布局

1

2

3

4

5

6

7

8

9

10

11

12

#程序所在位置

C:/mysql

#配置文件所在位置

C:/mysql/my.ini

#数据文件存放位置

D:/ProgramData/MySQL/data

#pid文件位置

D:/ProgramData/MySQL/run

#tmp位置

D:/ProgramData/MySQL/tmp

#日志文件位置

D:/ProgramData/MySQL/logs

5、配置my.ini文件

在C:/mysql文件夹下新建my.ini文件,具体内容如下:

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

[client]

port = 3306

socket = D:\\ProgramData\\MySQL\\tmp\\mysql.sock

#default-character-set=utf8mb4

character_sets_dir = C:/mysql/share/charsets

[mysqld]

port = 3306

socket = D:\\ProgramData\\MySQL\\tmp\\mysql.sock

pid_file = D:\\ProgramData\\MySQL\\run\\mysql.pid

basedir = C:\\mysql

datadir = D:\\ProgramData\\MySQL\\data

skip-external-locking

key_buffer_size = 16M

max_allowed_packet = 1M

table_open_cache = 64

sort_buffer_size = 512K

net_buffer_length = 8K

read_buffer_size = 256K

read_rnd_buffer_size = 512K

myisam_sort_buffer_size = 8M

default-storage-engine = InnoDB

# 从8.0 开始,mysql默认字符集为utf8mb4

character_set_server = utf8mb4

character_sets_dir = C:/mysql/share/charsets

tmpdir = D:\\ProgramData\\MySQL\\tmp\\

log-bin=D:\\ProgramData\\MySQL\\logs\\mysql-bin

#bin log 过期时间 按秒记,即14*24*60*60 秒

binlog_expire_logs_seconds = 1209600

# binary logging format - mixed recommended

binlog_format=row

#expire_logs_days= 7

log-error = D:\\ProgramData\\MySQL\\logs\\error.log

slow-query-log = 1

long_query_time= 3

slow_query_log_file= D:\\ProgramData\\MySQL\\logs\\slow.log

# required unique id between 1 and 2^32 - 1

# defaults to 1 if master-host is not set

# but will not function as a master if omitted

server-id = 1

# Uncomment the following if you are using InnoDB tables

innodb_data_home_dir = D:\\ProgramData\\MySQL\\data

innodb_data_file_path = ibdata1:10M:autoextend

innodb_log_group_home_dir = D:\\ProgramData\\MySQL\\logs

# You can set .._buffer_pool_size up to 50 - 80 %

# of RAM but beware of setting memory usage too high

innodb_buffer_pool_size = 16M

#innodb_additional_mem_pool_size = 2M

# Set .._log_file_size to 25 % of buffer pool size

innodb_log_file_size = 5M

innodb_log_buffer_size = 8M

innodb_flush_log_at_trx_commit = 1

innodb_lock_wait_timeout = 50

innodb_file_per_table = 1

[mysqldump]

quick

max_allowed_packet = 16M

[mysql]

no-auto-rehash

# Remove the next comment character if you are not familiar with SQL

#safe-updates

[myisamchk]

key_buffer_size = 20M

sort_buffer_size = 20M

read_buffer = 2M

write_buffer = 2M

[mysqlhotcopy]

interactive-timeout

6、初始化MySQL

使用管理员打开CMD程序,切换到mysql的bin目录下面,执行如下命令:

1

mysqld.exe --initialize  --basedir="c:/mysql" --datadir="D:/programdata/mysql/data"

7、启动应用程序

使用–console参数查看输出

1

mysqld.exe --defaults-file="C:/mysql/my.ini" --console

–defaults-file参数必须作为mysqld的第一个参数,不然会报“ unknown variable ‘defaults-file=C:/mysql/my.ini’”的错误。

8、登陆MySQL

MySQL初始化的时候会在error.log文件内生成一个临时密码,使用该密码登陆root 用户,将密码进行重置。

1

alter user 'root'@'localhost' identified by 'yourpassword';

9、将MySQL安装为系统服务

1

mysqld.exe --install MySQL --defaults-file=C:/mysql/my.ini

若要删除mysql服务,则执行

1

mysqld.exe --remove

Enjoy It!祝君使用愉快!

猜你喜欢

转载自blog.csdn.net/English0523/article/details/81456016