最近看了看MySQL,MySQL到8.0后有很大的性能提升,为了做一些数据库的配置,看了下MySQL8.0在win10上安装多个mysql,在这里分享给大家
准备
下载MySQL8.0MySQL8.0下载地址,根据自己的情况下载32或者64位的
安装
1、解压下载的MySQL8.0压缩包,放到你准备好的目录下,我这里放到D:\MySQL\mysql1下的;
2、在文件夹下,创建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:\Mysql\mysql1
datadir = D:\Mysql\mysql1\data
port = 3306
#binlog-do-db=leven #待同步的数据库
# server_id = .....
#忘记密码时使用
#skip-grant-tables
#设置协议认证方式(重点啊)
#default_authentication_plugin=mysql_native_password
# 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
3、初始化数据库,进入mysql1下的bin目录下,cmd执行命令:mysqld –initialize –console,执行后会打印出默认密码(记住这个密码),你这时候就可以看到mysql1下有一个data文件夹,下面有很多文件
2018-06-20T07:34:05.46124Z 5 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: JPPWSDF&jsl(
4、安装服务,在bin目录下执行命令 mysqld –install [服务名],这里的服务名默认mysql,我这里是要安装多个,所以区分一下,服务名为mysql1;
5、开启服务,执行命令net start 服务名 (注意这里执行命令要在管理员模式下,不然权限不够不能执行)
6、然后就可以在bin目录下运行MySQL了,执行 mysql -uroot -p ,然后输入刚才记住的密码,就可以进行登陆了;
7、默认生成的密码很难记,所以这里要自己改一下,进入到MySQL后执行代码
ALTER user 'root'@'localhost' IDENTIFIED BY 'Dd1123#'
密码要包含大写字母,小写字母,数字,特殊符号,不然会报错;
创建其他mysql
在D:\MySQL下创建一个mysql2文件夹,把mysql1中的文件复制过来,然后删除data文夹,修改my.ini中的这几句
basedir = D:\Mysql\mysql1
datadir = D:\Mysql\mysql1\data
port = 3306
修改为
basedir = D:\Mysql\mysql2
datadir = D:\Mysql\mysql2\data
port = 3307
然后和上面操作一样,初始化数据库,安装服务,开启服务,进入mysql,记住登陆的时候使用mysql -uroot -P3307 -p来登陆区分几个数据;不写-P默认3306;
完结。