首页 > 代码库 > mysql一机多实例安装记录

mysql一机多实例安装记录

因为想研究mycat,所以需要安装多个mysql实例进行研究。限于没有多于计算机,只能在本机安装了。通过mysql文档,自己琢磨着安装成功!

目录结构如下:

技术分享

其中one和two文件夹用来模拟数据库分库。

 

操作步骤:

 

拷贝文件

拷贝mysql-5.7.9-win64目录下的my-default.ini分别到whole、one、two目录下,更名为my.init。

 

以whole库 为例说明,one库和two库做相应调整即可。

1、编写\instance\whole\my.init

 

innodb_buffer_pool_size = 128M

basedir = E:\mysql\mysql-5.7.9-winx64

datadir = E:\mysql\mysql-5.7.9-winx64\instance\whole\data

port = 3309

server_id = 3

 

对于分库two要注意:

技术分享

3、Initializing the Data Directory 

mysqld --defaults-file=E:\mysql\instance\whole\my.ini --initialize --console

 

2017-01-23T01:31:39.492351Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defau

lts_for_timestamp server option (see documentation for more details).

2017-01-23T01:31:39.492351Z 0 [Warning] ‘NO_ZERO_DATE‘, ‘NO_ZERO_IN_DATE‘ and ‘ERROR_FOR_DIVISION_BY_ZERO‘ sql modes sho

uld be used with strict mode. They will be merged with strict mode in a future release.

2017-01-23T01:31:39.492351Z 0 [Warning] ‘NO_AUTO_CREATE_USER‘ sql mode was not set.

2017-01-23T01:31:41.487351Z 0 [Warning] InnoDB: New log files created, LSN=45790

2017-01-23T01:31:41.980351Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.

2017-01-23T01:31:42.145351Z 0 [Warning] No existing UUID has been found, so we assume that this is the first time that t

his server has been started. Generating a new UUID: b192bf10-e10b-11e6-b19c-00ffcdaad4ca.

2017-01-23T01:31:42.193351Z 0 [Warning] Gtid table is not ready to be used. Table ‘mysql.gtid_executed‘ cannot be opened

.

2017-01-23T01:31:42.218351Z 1 [Note] A temporary password is generated for root@localhost: g0tN0uAqak>e

 

4、启动服务

mysqld --defaults-file=E:\mysql\instance\whole\my.ini --console 

5、测试连接:

mysql -h localhost -u root --port 3309 -p

技术分享

 

mysql> set password=password(‘123‘);

Query OK, 0 rows affected, 1 warning (0.00 sec)

 


 

mysql 文档中,修改密码用的是:ALTER USER ‘root‘@‘localhost‘ IDENTIFIED BY ‘new_password‘; 

mysql> alter user ‘root‘@‘localhost‘ password expire never;

Query OK, 0 rows affected (0.00 sec)

 

mysql> show databases;

+--------------------+

| Database           |

+--------------------+

| information_schema |

| mysql              |

| performance_schema |

| sys                |

+--------------------+

4 rows in set (0.00 sec)

 

 

6、关闭服务

mysqladmin -h localhost --port 3309 -p  -u root shutdown

 

7、安装为服务

mysqld --install-manual MySqlWhole  --defaults-file=E:\mysql\instance\whole\my.ini

Service successfully installed.

 

word文件

 

windows服务管理中:

技术分享

 

mysql一机多实例安装记录