windows同时安装 5.7 8.0 mysql

打印 上一主题 下一主题

主题 842|帖子 842|积分 2536

电脑配置升级了,想着自己电脑当地安装数据库,重新学习一下MySQL,下面记载了当地Windows安装两个版本MySQL的过程。
一.安装5.7版本

(1)在解压目录创建配置文件 - my.ini
  1. [mysqld]
  2. # set basedir to your installation path
  3. basedir=D:/Program/mysql/mysql-5.7.24-winx64
  4. # set datadir to the location of your data directory
  5. datadir=D:/Program/mysql/mysql-5.7.24-winx64/data
复制代码
(2)创建data文件夹,初始化数据目录:留意有两种选项


  • --initialize:默认的安全安装模式,会天生随机初始的root暗码,这种情况下,暗码被标记为过期,第一次登岸进去后需要设置新的暗码
  • --initialize-insecure:不安全的安装模式,不会root天生暗码
  • --user:指定用户
  1. ## 初始化数据目录,使用第一种方式
  2. PS D:\Program\mysql\mysql-5.7.24-winx64\bin> .\mysqld --initialize --user=hecg95
复制代码
(3)首次启动:
  1. ## 启动MySQL
  2. PS D:\Program\mysql\mysql-5.7.24-winx64\bin> .\mysqld --console
  3. ...
  4. 2020-01-06T12:06:55.258100Z 0 [Note] InnoDB: Mutexes and rw_locks use Windows interlocked functions
  5. 2020-01-06T12:06:55.258762Z 0 [Note] InnoDB: Uses event mutexes
  6. 2020-01-06T12:06:55.259034Z 0 [Note] InnoDB: _mm_lfence() and _mm_sfence() are used for memory barrier
  7. 2020-01-06T12:06:55.259223Z 0 [Note] InnoDB: Compressed tables use zlib 1.2.11
  8. 2020-01-06T12:06:55.259652Z 0 [Note] InnoDB: Number of pools: 1
  9. 2020-01-06T12:06:55.259933Z 0 [Note] InnoDB: Not using CPU crc32 instructions
  10. 2020-01-06T12:06:55.263195Z 0 [Note] InnoDB: Initializing buffer pool, total size = 128M, instances = 1, chunk size = 128M
  11. 2020-01-06T12:06:55.268347Z 0 [Note] InnoDB: Completed initialization of buffer pool
  12. 2020-01-06T12:06:55.313150Z 0 [Note] InnoDB: Highest supported file format is Barracuda.
  13. 2020-01-06T12:06:55.366453Z 0 [Note] InnoDB: Creating shared tablespace for temporary tables
  14. 2020-01-06T12:06:55.367217Z 0 [Note] InnoDB: Setting file '.\ibtmp1' size to 12 MB. Physically writing the file full; Please wait ...
  15. 2020-01-06T12:06:55.415184Z 0 [Note] InnoDB: File '.\ibtmp1' size is now 12 MB.
  16. 2020-01-06T12:06:55.422146Z 0 [Note] InnoDB: 96 redo rollback segment(s) found. 96 redo rollback segment(s) are active.
  17. 2020-01-06T12:06:55.422578Z 0 [Note] InnoDB: 32 non-redo rollback segment(s) are active.
  18. 2020-01-06T12:06:55.423030Z 0 [Note] InnoDB: Waiting for purge to start
  19. 2020-01-06T12:06:55.484660Z 0 [Note] InnoDB: 5.7.24 started; log sequence number 2591440
  20. 2020-01-06T12:06:55.485287Z 0 [Note] Plugin 'FEDERATED' is disabled.
  21. 2020-01-06T12:06:55.485644Z 0 [Note] InnoDB: Loading buffer pool(s) from D:\Program\mysql\mysql-5.7.24-winx64\data\ib_buffer_pool
  22. 2020-01-06T12:06:55.495151Z 0 [Warning] Failed to set up SSL because of the following SSL library error: SSL context is not usable without certificate and private key
  23. 2020-01-06T12:06:55.497758Z 0 [Note] Server hostname (bind-address): '*'; port: 3306
  24. 2020-01-06T12:06:55.498298Z 0 [Note] IPv6 is available.
  25. 2020-01-06T12:06:55.499141Z 0 [Note]   - '::' resolves to '::';
  26. 2020-01-06T12:06:55.499488Z 0 [Note] Server socket created on IP: '::'.
  27. 2020-01-06T12:06:55.503746Z 0 [Note] InnoDB: Buffer pool(s) load completed at 200106 20:06:55
  28. 2020-01-06T12:06:55.540602Z 0 [Note] Event Scheduler: Loaded 0 events
  29. 2020-01-06T12:06:55.541097Z 0 [Note] D:\Program\mysql\mysql-5.7.24-winx64\bin\mysqld.exe: ready for connections.
  30. Version: '5.7.24'  socket: ''  port: 3306  MySQL Community Server (GPL)
复制代码
(4)查找暗码及修改暗码:


  • 随机暗码在data目录下的hqiogwdt0114.err文件中:wD2q)XQF%*nz
    1. 2020-01-06T12:04:46.034179Z 1 [Note] A temporary password is generated for root@localhost: wD2q)XQF%*nz
    复制代码
  • 使用初始暗码登岸MySQL,重新设置新的暗码:
    1. PS D:\Program\mysql\mysql-5.7.24-winx64\bin> .\mysql -u root -p
    2. Enter password: ************
    3. Welcome to the MySQL monitor.  Commands end with ; or \g.
    4. Your MySQL connection id is 6
    5. Server version: 5.7.24
    6. Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.
    7. Oracle is a registered trademark of Oracle Corporation and/or its
    8. affiliates. Other names may be trademarks of their respective
    9. owners.
    10. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
    11. mysql> use mysql
    12. ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.
    13. ## 首次登陆,提示需要修改密码
    14. mysql> set password="123456";
    15. Query OK, 0 rows affected (0.00 sec)
    16. mysql> exit
    17. Bye
    18. PS D:\Program\mysql\mysql-5.7.24-winx64\bin>
    复制代码
  • 使用mysqladmin关闭和重新启动MySQL:
    1. PS D:\Program\mysql\mysql-5.7.24-winx64\bin> .\mysqladmin -u root shutdown
    2. mysqladmin: connect to server at 'localhost' failed
    3. error: 'Access denied for user 'root'@'localhost' (using password: NO)'
    4. ## 需要密码
    5. PS D:\Program\mysql\mysql-5.7.24-winx64\bin> .\mysqladmin -u root shutdown -p
    6. Enter password: ******
    7. ## 重新启动 --console 会输出日志
    8. PS D:\Program\mysql\mysql-5.7.24-winx64\bin> .\mysqld --console
    9. ...
    10. 2020-01-06T12:36:09.767463Z 0 [Note] InnoDB: Mutexes and rw_locks use Windows interlocked functions
    11. 2020-01-06T12:36:09.767981Z 0 [Note] InnoDB: Uses event mutexes
    12. 2020-01-06T12:36:09.768364Z 0 [Note] InnoDB: _mm_lfence() and _mm_sfence() are used for memory barrier
    13. 2020-01-06T12:36:09.776583Z 0 [Note] InnoDB: Compressed tables use zlib 1.2.11
    14. 2020-01-06T12:36:09.779705Z 0 [Note] InnoDB: Number of pools: 1
    15. 2020-01-06T12:36:09.780609Z 0 [Note] InnoDB: Not using CPU crc32 instructions
    16. 2020-01-06T12:36:09.784180Z 0 [Note] InnoDB: Initializing buffer pool, total size = 128M, instances = 1, chunk size = 128M
    17. 2020-01-06T12:36:09.789972Z 0 [Note] InnoDB: Completed initialization of buffer pool
    18. 2020-01-06T12:36:09.840754Z 0 [Note] InnoDB: Highest supported file format is Barracuda.
    19. 2020-01-06T12:36:09.896882Z 0 [Note] InnoDB: Creating shared tablespace for temporary tables
    20. 2020-01-06T12:36:09.897805Z 0 [Note] InnoDB: Setting file '.\ibtmp1' size to 12 MB. Physically writing the file full; Please wait ...
    21. 2020-01-06T12:36:09.938564Z 0 [Note] InnoDB: File '.\ibtmp1' size is now 12 MB.
    22. 2020-01-06T12:36:09.953197Z 0 [Note] InnoDB: 96 redo rollback segment(s) found. 96 redo rollback segment(s) are active.
    23. 2020-01-06T12:36:09.953663Z 0 [Note] InnoDB: 32 non-redo rollback segment(s) are active.
    24. 2020-01-06T12:36:09.957244Z 0 [Note] InnoDB: Waiting for purge to start
    25. 2020-01-06T12:36:10.010316Z 0 [Note] InnoDB: 5.7.24 started; log sequence number 2591496
    26. 2020-01-06T12:36:10.012857Z 0 [Note] Plugin 'FEDERATED' is disabled.
    27. 2020-01-06T12:36:10.014410Z 0 [Note] InnoDB: Loading buffer pool(s) from D:\Program\mysql\mysql-5.7.24-winx64\data\ib_buffer_pool
    28. 2020-01-06T12:36:10.030225Z 0 [Warning] Failed to set up SSL because of the following SSL library error: SSL context is not usable without certificate and private key
    29. 2020-01-06T12:36:10.033015Z 0 [Note] Server hostname (bind-address): '*'; port: 3306
    30. 2020-01-06T12:36:10.037653Z 0 [Note] IPv6 is available.
    31. 2020-01-06T12:36:10.038029Z 0 [Note]   - '::' resolves to '::';
    32. 2020-01-06T12:36:10.039131Z 0 [Note] Server socket created on IP: '::'.
    33. 2020-01-06T12:36:10.045001Z 0 [Note] InnoDB: Buffer pool(s) load completed at 200106 20:36:10
    34. 2020-01-06T12:36:10.076855Z 0 [Note] Event Scheduler: Loaded 0 events
    35. 2020-01-06T12:36:10.077455Z 0 [Note] D:\Program\mysql\mysql-5.7.24-winx64\bin\mysqld.exe: ready for connections.
    36. Version: '5.7.24'  socket: ''  port: 3306  MySQL Community Server (GPL)
    37. ## 监听到关闭信号
    38. 2020-01-06T12:36:28.761907Z 0 [Note] D:\Program\mysql\mysql-5.7.24-winx64\bin\mysqld.exe: Normal shutdown
    39. 2020-01-06T12:36:28.762424Z 0 [Note] Giving 0 client threads a chance to die gracefully
    40. 2020-01-06T12:36:28.763869Z 0 [Note] Shutting down slave threads
    41. 2020-01-06T12:36:28.763943Z 0 [Note] Forcefully disconnecting 0 remaining clients
    42. 2020-01-06T12:36:28.772298Z 0 [Note] Event Scheduler: Purging the queue. 0 events
    43. 2020-01-06T12:36:28.775985Z 0 [Note] Binlog end
    44. 2020-01-06T12:36:28.779654Z 0 [Note] Shutting down plugin 'ngram'
    45. 2020-01-06T12:36:28.779782Z 0 [Note] Shutting down plugin 'partition'
    46. 2020-01-06T12:36:28.780434Z 0 [Note] Shutting down plugin 'BLACKHOLE'
    47. 2020-01-06T12:36:28.780889Z 0 [Note] Shutting down plugin 'ARCHIVE'
    48. 2020-01-06T12:36:28.781495Z 0 [Note] Shutting down plugin 'PERFORMANCE_SCHEMA'
    49. 2020-01-06T12:36:28.782033Z 0 [Note] Shutting down plugin 'MRG_MYISAM'
    50. 2020-01-06T12:36:28.782711Z 0 [Note] Shutting down plugin 'MyISAM'
    51. 2020-01-06T12:36:28.783141Z 0 [Note] Shutting down plugin 'INNODB_SYS_VIRTUAL'
    52. 2020-01-06T12:36:28.783563Z 0 [Note] Shutting down plugin 'INNODB_SYS_DATAFILES'
    53. 2020-01-06T12:36:28.784021Z 0 [Note] Shutting down plugin 'INNODB_SYS_TABLESPACES'
    54. 2020-01-06T12:36:28.784406Z 0 [Note] Shutting down plugin 'INNODB_SYS_FOREIGN_COLS'
    55. 2020-01-06T12:36:28.787567Z 0 [Note] Shutting down plugin 'INNODB_SYS_FOREIGN'
    56. 2020-01-06T12:36:28.794063Z 0 [Note] Shutting down plugin 'INNODB_SYS_FIELDS'
    57. 2020-01-06T12:36:28.794995Z 0 [Note] Shutting down plugin 'INNODB_SYS_COLUMNS'
    58. 2020-01-06T12:36:28.795741Z 0 [Note] Shutting down plugin 'INNODB_SYS_INDEXES'
    59. 2020-01-06T12:36:28.796564Z 0 [Note] Shutting down plugin 'INNODB_SYS_TABLESTATS'
    60. 2020-01-06T12:36:28.797016Z 0 [Note] Shutting down plugin 'INNODB_SYS_TABLES'
    61. 2020-01-06T12:36:28.797522Z 0 [Note] Shutting down plugin 'INNODB_FT_INDEX_TABLE'
    62. 2020-01-06T12:36:28.798010Z 0 [Note] Shutting down plugin 'INNODB_FT_INDEX_CACHE'
    63. 2020-01-06T12:36:28.798490Z 0 [Note] Shutting down plugin 'INNODB_FT_CONFIG'
    64. 2020-01-06T12:36:28.798970Z 0 [Note] Shutting down plugin 'INNODB_FT_BEING_DELETED'
    65. 2020-01-06T12:36:28.799438Z 0 [Note] Shutting down plugin 'INNODB_FT_DELETED'
    66. 2020-01-06T12:36:28.799871Z 0 [Note] Shutting down plugin 'INNODB_FT_DEFAULT_STOPWORD'
    67. 2020-01-06T12:36:28.800360Z 0 [Note] Shutting down plugin 'INNODB_METRICS'
    68. 2020-01-06T12:36:28.804643Z 0 [Note] Shutting down plugin 'INNODB_TEMP_TABLE_INFO'
    69. 2020-01-06T12:36:28.804719Z 0 [Note] Shutting down plugin 'INNODB_BUFFER_POOL_STATS'
    70. 2020-01-06T12:36:28.811108Z 0 [Note] Shutting down plugin 'INNODB_BUFFER_PAGE_LRU'
    71. 2020-01-06T12:36:28.813588Z 0 [Note] Shutting down plugin 'INNODB_BUFFER_PAGE'
    72. 2020-01-06T12:36:28.815982Z 0 [Note] Shutting down plugin 'INNODB_CMP_PER_INDEX_RESET'
    73. 2020-01-06T12:36:28.824638Z 0 [Note] Shutting down plugin 'INNODB_CMP_PER_INDEX'
    74. 2020-01-06T12:36:28.825589Z 0 [Note] Shutting down plugin 'INNODB_CMPMEM_RESET'
    75. 2020-01-06T12:36:28.834224Z 0 [Note] Shutting down plugin 'INNODB_CMPMEM'
    76. 2020-01-06T12:36:28.837309Z 0 [Note] Shutting down plugin 'INNODB_CMP_RESET'
    77. 2020-01-06T12:36:28.838494Z 0 [Note] Shutting down plugin 'INNODB_CMP'
    78. 2020-01-06T12:36:28.838905Z 0 [Note] Shutting down plugin 'INNODB_LOCK_WAITS'
    79. 2020-01-06T12:36:28.839309Z 0 [Note] Shutting down plugin 'INNODB_LOCKS'
    80. 2020-01-06T12:36:28.839723Z 0 [Note] Shutting down plugin 'INNODB_TRX'
    81. 2020-01-06T12:36:28.840115Z 0 [Note] Shutting down plugin 'InnoDB'
    82. 2020-01-06T12:36:28.840561Z 0 [Note] InnoDB: FTS optimize thread exiting.
    83. 2020-01-06T12:36:28.841021Z 0 [Note] InnoDB: Starting shutdown...
    84. 2020-01-06T12:36:28.957313Z 0 [Note] InnoDB: Dumping buffer pool(s) to D:\Program\mysql\mysql-5.7.24-winx64\data\ib_buffer_pool
    85. 2020-01-06T12:36:28.962702Z 0 [Note] InnoDB: Buffer pool(s) dump completed at 200106 20:36:28
    86. 2020-01-06T12:36:29.731460Z 0 [Note] InnoDB: Shutdown completed; log sequence number 2591524
    87. 2020-01-06T12:36:29.732301Z 0 [Note] InnoDB: Removed temporary tablespace data file: "ibtmp1"
    88. 2020-01-06T12:36:29.739414Z 0 [Note] Shutting down plugin 'MEMORY'
    89. 2020-01-06T12:36:29.739625Z 0 [Note] Shutting down plugin 'CSV'
    90. 2020-01-06T12:36:29.739704Z 0 [Note] Shutting down plugin 'sha256_password'
    91. 2020-01-06T12:36:29.739775Z 0 [Note] Shutting down plugin 'mysql_native_password'
    92. 2020-01-06T12:36:29.739990Z 0 [Note] Shutting down plugin 'binlog'
    93. 2020-01-06T12:36:29.741858Z 0 [Note] D:\Program\mysql\mysql-5.7.24-winx64\bin\mysqld.exe: Shutdown complete
    复制代码
二.安装8.0版本

(1)在解压目录创建配置文件 - my.ini
  1. [mysqld]
  2. # set basedir to your installation path
  3. basedir=D:/Program/mysql/mysql-8.0.18-winx64
  4. # set datadir to the location of your data directory
  5. datadir=D:/Program/mysql/mysql-8.0.18-winx64/data
  6. # 多个MySQL时,修改port,换个端口号
  7. port = 13306
复制代码
(2)创建data文件夹,初始化数据目录:留意有两种选项


  • --initialize:默认的安全安装模式,会天生随机初始的root暗码,这种情况下,暗码被标记为过期,第一次登岸进去后需要设置新的暗码
  • --initialize-insecure:不安全的安装模式,不会root天生暗码,默认为空暗码
  • --user:指定用户
  • 参考官网的文档 - 2.10.1 Initializing the Data Directory
  1. ## 初始化数据目录,使用第二种方初始化自动创建data文件夹
  2. PS D:\Program\mysql\mysql-8.0.18-winx64\bin> .\mysqld --initialize-insecure --user=hecg95
复制代码
(3)首次启动:
  1. ## 启动MySQL
  2. PS D:\Program\mysql\mysql-8.0.18-winx64\bin> .\mysqld --console
  3. 2020-01-06T12:58:00.798580Z 0 [System] [MY-010116] [Server] D:\Program\mysql\mysql-8.0.18-winx64\bin\mysqld.exe (mysqld 8.0.18) starting as process 33124
  4. 2020-01-06T12:58:01.573236Z 0 [Warning] [MY-010068] [Server] CA certificate ca.pem is self signed.
  5. 2020-01-06T12:58:01.604355Z 0 [System] [MY-010931] [Server] D:\Program\mysql\mysql-8.0.18-winx64\bin\mysqld.exe: ready for connections. Version: '8.0.18'  socket: ''  port: 13306  MySQL Community Server - GPL.
  6. 2020-01-06T12:58:01.618988Z 0 [System] [MY-011323] [Server] X Plugin ready for connections. Bind-address: '::' port: 33060
复制代码
(4)初次登岸及修改暗码:


  • 查察data目录下的hqiogwdt0114.err文件:提示现在使用默认的空暗码
    1. 2020-01-06T12:51:51.897459Z 5 [Warning] [MY-010453] [Server] root@localhost is created with an empty password ! Please consider switching off the --initialize-insecure option.
    复制代码
  启动8.0 服务  mysqld install MySQL80 --defaults-file="D:\DevelopTool\MySQL\mysql-5.7.42\my.ini"  开启服务(管理员打开的cmd窗口开启服务)  mysqld --install mysql88 --defaults-file="E:\mysql-8.0.39-winx64\mysql-8.0.39-winx64\my.ini"  

  • 使用空暗码登岸MySQL,重新设置新的暗码:
    在MySQL 8.0中,默认的身份验证插件已从更改 mysql_native_password为 caching_sha2_password,并且 'root'@'localhost'管理帐户caching_sha2_password默认使用。
    1. PS D:\Program\mysql\mysql-8.0.18-winx64\bin> .\mysql -P 13306  -u root -p
    2. Enter password:
    3. Welcome to the MySQL monitor.  Commands end with ; or \g.
    4. Your MySQL connection id is 9
    5. Server version: 8.0.18 MySQL Community Server - GPL
    6. Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved.
    7. Oracle is a registered trademark of Oracle Corporation and/or its
    8. affiliates. Other names may be trademarks of their respective
    9. owners.
    10. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
    11. mysql> use mysql
    12. Database changed
    13. ## 注意此处不同于之前的版本
    14. mysql> ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '123456';
    15. Query OK, 0 rows affected (0.01 sec)
    16. mysql> FLUSH PRIVILEGES;
    17. Query OK, 0 rows affected (0.01 sec)
    18. ## 否则客户端连接会报错
    19. 1251 - Client does not support authentication protocol requested by server; consider upgrading MySQL client
    复制代码
  • 使用mysqladmin关闭和重新启动MySQL:
    1. ## 关闭MySQL
    2. PS D:\Program\mysql\mysql-8.0.18-winx64\bin> .\mysqladmin -P 13306 -u root shutdown -p
    3. Enter password: ******
    4. ## 监听到关闭信号
    5. 2020-01-06T13:21:31.470768Z 15 [System] [MY-013172] [Server] Received SHUTDOWN from user root. Shutting down mysqld (Version: 8.0.18).
    6. 2020-01-06T13:21:31.473233Z 0 [System] [MY-013105] [Server] D:\Program\mysql\mysql-8.0.18-winx64\bin\mysqld.exe: Normal shutdown.
    7. 2020-01-06T13:21:31.766555Z 0 [System] [MY-010910] [Server] D:\Program\mysql\mysql-8.0.18-winx64\bin\mysqld.exe: Shutdown complete (mysqld 8.0.18)  MySQL Community Server - GPL.
    8. ## 重新启动 --console 会输出日志
    9. PS D:\Program\mysql\mysql-8.0.18-winx64\bin> .\mysqld --console
    10. 2020-01-06T13:23:27.071931Z 0 [System] [MY-010116] [Server] D:\Program\mysql\mysql-8.0.18-winx64\bin\mysqld.exe (mysqld 8.0.18) starting as process 24388
    11. 2020-01-06T13:23:27.696975Z 0 [Warning] [MY-010068] [Server] CA certificate ca.pem is self signed.
    12. 2020-01-06T13:23:27.732170Z 0 [System] [MY-010931] [Server] D:\Program\mysql\mysql-8.0.18-winx64\bin\mysqld.exe: ready for connections. Version: '8.0.18'  socket: ''  port: 13306  MySQL Community Server - GPL.
    13. 2020-01-06T13:23:27.862052Z 0 [System] [MY-011323] [Server] X Plugin ready for connections. Bind-address: '::' port: 33060
    复制代码

免责声明:如果侵犯了您的权益,请联系站长,我们会及时删除侵权内容,谢谢合作!更多信息从访问主页:qidao123.com:ToB企服之家,中国第一个企服评测及商务社交产业平台。
回复

使用道具 举报

0 个回复

正序浏览

快速回复

您需要登录后才可以回帖 登录 or 立即注册

本版积分规则

来自云龙湖轮廓分明的月亮

金牌会员
这个人很懒什么都没写!
快速回复 返回顶部 返回列表