MySQL Community Server 8.0.18安装配置(Windows)及示例Employee库导入

下载地址

https://dev.mysql.com/downloads/mysql/

配置文件

配置文件在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

查看所有的配置项,可参考:https://dev.mysql.com/doc/refman/8.0/en/mysqld-option-tables.html

初始化数据库

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

mysqld --initialize --console

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

要是关快了,或者没记住,那也没事,删掉初始化的 datadir 目录,再执行一遍初始化命令,又会重新生成。

安装服务

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

mysqld --install [服务名]

后面的服务名可以不写,默认的名字为 mysql。当然,如果你的电脑上需要安装多个MySQL服务,就可以用不同的名字区分了,比如 mysql5 和 mysql8。安装完成之后,就可以通过命令

net start mysql

启动MySQL的服务了。

更改密码和密码认证插件

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

mysql -uroot -p

在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

navicat配置

mysql测试数据库导入

mysql官方自带了一个测试数据库employees,方便测试使用。

github地址:https://github.com/datacharmer/test_db
mysql官方的安装说明:https://dev.mysql.com/doc/employee/en/
安装测试命令:

git clone https://github.com/datacharmer/test_db
unzip test_db-master.zip
cd test_db-master/
mysql -uroot -ppassword < employees.sql 
mysql -uroot -ppassword < test_employees_md5.sql 

6张表的ER图如图:

mysql示例数据 employee,这个大家也可以到github官网下载。 https://github.com/datacharmer/test_db test_db A sample database with an integrated test suite, used to test your applications and database servers This repository was migrated from Launchpad. See usage in the MySQL docs Where it comes from The original data was created by Fusheng Wang and Carlo Zaniolo at Siemens Corporate Research. The data is in XML format. http://timecenter.cs.aau.dk/software.htm Giuseppe Maxia made the relational schema and Patrick Crews exported the data in relational format. The database contains about 300,000 employee records with 2.8 million salary entries. The export data is 167 MB, which is not huge, but heavy enough to be non-trivial for testing. The data was generated, and as such there are inconsistencies and subtle problems. Rather than removing them, we decided to leave the contents untouched, and use these issues as data cleaning exercises. Prerequisites You need a MySQL database server (5.0+) and run the commands below through a user that has the following privileges: SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, RELOAD, REFERENCES, INDEX, ALTER, SHOW DATABASES, CREATE TEMPORARY TABLES, LOCK TABLES, EXECUTE, CREATE VIEW Installation: Download the repository Change directory to the repository Then run mysql < employees.sql If you want to install with two large partitioned tables, run mysql < employees_partitioned.sql Testing the installation After installing, you can run one of the following mysql -t < test_employees_md5.sql # OR mysql -t < test_employees_sha.sql For example: mysql -t < test_employees_md5.sql +----------------------+ | INFO | +----------------------+ | TESTING INSTALLATION | +----------------------+ +--------------+------------------+----------------------------------+ | table_name | expected_records | expected_crc | +--------------+------------------+----------------------------------+ | employees | 300024 |
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值