当前位置: 移动技术网 > IT编程>数据库>Mysql > mysql 8.0 Windows zip包版本安装详细过程

mysql 8.0 Windows zip包版本安装详细过程

2018年08月08日  | 移动技术网IT编程  | 我要评论

mysql 8.0 windows zip 安装过程介绍,具体如下

准备:

mysql8.0 windows zip包。

环境:windows 10

一、安装

1. 解压zip包到安装目录

比如我的安装目录是:d:\program\mysql

2.配置文件

在windows系统中,配置文件默认是安装目录下的 my.ini 文件,部分配置需要在初始安装时配置,大部分也可以在安装完成后进行更改。当然,极端情况下,所有的都是可以更改的。

在安装根目录下添加 my.ini,比如我这里是:d:\program\mysql\my.ini,写入基本配置:

[mysqld]
# remove leading # and set to the amount of ram for the most important data
# cache in mysql. start at 70% of total ram for dedicated server, else 10%.
# innodb_buffer_pool_size = 128m

# remove leading # to turn on a very important data integrity option: logging
# changes to the binary log between backups.
# log_bin

# these are commonly set, remove the # and set as required.
basedir = d:\program\mysql
datadir = d:\dbs\mysql
port = 3306
# server_id = .....


# remove leading # to set options mainly useful for reporting servers.
# the server defaults are faster for transactions and fast selects.
# adjust sizes as needed, experiment to find the optimal values.
# join_buffer_size = 128m
# sort_buffer_size = 2m
# read_rnd_buffer_size = 2m 

sql_mode=no_engine_substitution,strict_trans_tables 

character-set-server = utf8mb4

performance_schema_max_table_instances = 600
table_definition_cache = 400
table_open_cache = 256

[mysql]
default-character-set = utf8mb4

[client]
default-character-set = utf8mb4

注意,里面的 basedir 是我本地的安装目录,datadir 是我数据库数据文件要存放的位置,各项配置需要根据自己的环境进行配置。

查看所有的配置项,可参考:mysql 8.0 reference manual

3.初始化数据库

在mysql安装目录的 bin 目录下执行命令:

mysqld --initialize --console

执行完成后,会打印 root 用户的初始默认密码,比如:

2018-04-20t02:35:01.507037z 0 [warning] [my-010915] [server] 'no_zero_date', 'no_zero_in_date' and 'error_for_division_by_zero' sql modes should be used with strict mode. they will be merged with strict mode in a future release.
2018-04-20t02:35:01.507640z 0 [system] [my-013169] [server] d:\program\mysql8\bin\mysqld.exe (mysqld 8.0.11) initializing of server in progress as process 11064
2018-04-20t02:35:01.508173z 0 [error] [my-010340] [server] error message file 'd:\program\mysql\share\english\errmsg.sys' had only 1090 error messages, but it should contain at least 4512 error messages. check that the above file is the right version for this program!
2018-04-20t02:35:05.464644z 5 [note] [my-010454] [server] a temporary password is generated for root@localhost: apwcy5ws&hjq
2018-04-20t02:35:07.017280z 0 [system] [my-013170] [server] d:\program\mysql8\bin\mysqld.exe (mysqld 8.0.11) initializing of server has completed

其中,第4行的“apwcy5ws&hjq”就是初始密码,在没有更改密码前,需要记住这个密码,后续登录需要用到。

要是你手贱,关快了,或者没记住,那也没事,删掉初始化的 datadir 目录,再执行一遍初始化命令,又会重新生成的。当然,也可以使用安全工具,强制改密码,用什么方法,自己随意。

参考:

4.安装服务

在mysql安装目录的 bin 目录下执行命令:

mysqld --install [服务名]
后面的服务名可以不写,默认的名字为 mysql。当然,如果你的电脑上需要安装多个mysql服务,就可以用不同的名字区分了,比如 mysql5 和 mysql8。

安装完成之后,就可以通过命令net start mysql启动mysql的服务了。

参考:

二.更改密码和密码认证插件

在mysql安装目录的 bin 目录下执行命令:

mysql -uroot -p

这时候会提示输入密码,记住了第3步的密码,填入即可登录成功,进入mysql命令模式。

在mysql8.0.4以前,执行

set password=password('[修改的密码]');

就可以更改密码,但是mysql8.0.4开始,这样默认是不行的。因为之前,mysql的密码认证插件是“mysql_native_password”,而现在使用的是“caching_sha2_password”。

因为当前有很多数据库工具和链接包都不支持“caching_sha2_password”,为了方便,我暂时还是改回了“mysql_native_password”认证插件。

在mysql中执行命令:

alter user 'root'@'localhost' identified with mysql_native_password by 'password';

修改密码验证插件,同时修改密码。

如果想默认使用“mysql_native_password”插件认证,可以在配置文件中配置default_authentication_plugin项。

[mysqld]
default_authentication_plugin=mysql_native_password

参考:

三、速度测试

不用测了,官方说mysql8比5快两倍。

附、centos tar.gz 包安装

wget https://cdn.mysql.com//downloads/mysql-8.0/mysql-8.0.11-linux-glibc2.12-x86_64.tar.gz
shell> tar zxvf mysql-8.0.11-linux-glibc2.12-x86_64.tar.gz -c /usr/local/
shell> groupadd mysql
shell> useradd -r -g mysql -s /bin/false mysql
shell> cd /usr/local
shell> ln -s mysql-8.0.11-linux-glibc2.12-x86_64 mysql
shell> cd mysql
shell> mkdir mysql-files
shell> chown mysql:mysql mysql-files
shell> chmod 750 mysql-files
shell> bin/mysqld --initialize --user=mysql
shell> bin/mysql_ssl_rsa_setup
shell> bin/mysqld_safe --user=mysql &
# next command is optional
shell> cp support-files/mysql.server /etc/init.d/mysql.server

参考:

精彩专题分享:mysql不同版本安装教程 mysql5.7各版本安装教程 mysql5.6各版本安装教程

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

如对本文有疑问, 点击进行留言回复!!

相关文章:

验证码:
移动技术网