zoukankan      html  css  js  c++  java
  • win10 上面如何安装多个 MySQL8

    win10 上面如何安装多个 MySQL8

    1.官网下载 MySQL Community Downloads

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

    2.解压到你要安装的目录

    3.在MySQL的根目录下面新建my.ini的配置文件

    [mysqld]
    # 设置3306端口
    port=3306
    # 设置mysql的安装目录(需要设置为自己的安装目录)
    basedir=D:ProgrammingMySQL8MySQL1mysql-8.0.18-winx64
    # 设置mysql数据库的数据的存放目录(mysql-8.0.18不需要手动创建data文件夹)
    datadir=D:ProgrammingMySQL8MySQL1mysql-8.0.18-winx64data
    # 允许最大连接数
    max_connections=200
    # 允许连接失败的次数(这是为了防止有人从该主机试图攻击数据库系统)
    max_connect_errors=10
    # 服务端使用的字符集默认为utf8mb4
    character-set-server=utf8mb4
    # 创建新表时将使用的默认存储引擎
    default-storage-engine=INNODB
    # 默认使用mysql_native_password插件认证
    default_authentication_plugin=mysql_native_password
    # 去掉sql_mode中的only_full_group_by
    sql_mode=strict_trans_tables,no_zero_in_date,no_zero_date,error_for_division_by_zero,no_engine_substitution
    [mysql]
    # 设置mysql客户端默认字符集
    default-character-set=utf8mb4
    [client]
    # 设置mysql客户端连接服务端时默认使用的端口
    port=3306
    default-character-set=utf8mb4
    

    4.通过管理员的身份打开cmd窗口跳转路径到MySQL的bin目录

    # 进入到mysql的bin目录底下操作:
    # 初始化mysql
    mysqld --defaults-file=D:ProgrammingMySQL8MySQL1mysql-8.0.18-winx64my.ini --initialize --console
    
    # 安装mysql服务
    mysqld --install [服务名] MySQL1 --defaults-file=D:ProgrammingMySQL8MySQL1mysql-8.0.18-winx64my.ini
    mysqld --install MySQL1 --defaults-file=D:ProgrammingMySQL8MySQL1mysql-8.0.18-winx64my.ini
    
    # 启动mysql服务
    net start [服务名]
    net start mysql1
    
    # 停止mysql服务
    net stop [服务名]
    net stop mysql1
    
    # 卸载mysql服务
    mysqld -remove [服务名]
    mysqld --remove mysql1
    
    # 登录mysql
    mysql -h localhost -u root -P 3306 -p
    
    # 修改mysql密码
    alter user 'root'@'localhost' identified with mysql_native_password by '123456';
    
    flush privileges;
    
    # 开启mysql远程访问
    # 方式一:
    use mysql;
    
    create user 'root'@'%' identified by '123456';
    
    grant all on *.* to 'root'@'%';
    
    alter user 'root'@'%' identified with mysql_native_password by '123456';
    
    flush privileges;
    
    # 方式二:
    use mysql;
    
    select user,authentication_string,host from user;
    
    update user set host = '%' where user = 'root';
    
    flush privileges;
    
    alter user 'root'@'%' identified with mysql_native_password by '123456';
    

    5.其他

    MySQL2安装步骤

    D:ProgrammingMySQL8MySQL2mysql-8.0.18-winx64in>mysqld --defaults-file=D:ProgrammingMySQL8MySQL2mysql-8.0.18-winx64my.ini --initialize --console
    2019-11-06T13:19:04.091682Z 0 [System] [MY-013169] [Server] D:ProgrammingMySQL8MySQL2mysql-8.0.18-winx64inmysqld.exe (mysqld 8.0.18) initializing of server in progress as process 3276
    2019-11-06T13:19:07.073501Z 5 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: X>cZPPE6Qkpi
    
    D:ProgrammingMySQL8MySQL2mysql-8.0.18-winx64in>mysqld --install MySQL2 --defaults-file=D:ProgrammingMySQL8MySQL2mysql-8.0.18-winx64my.ini
    Service successfully installed.
    
    D:ProgrammingMySQL8MySQL2mysql-8.0.18-winx64in>net start mysql2
    MySQL2 服务正在启动 .
    MySQL2 服务已经启动成功。
    
    
    D:ProgrammingMySQL8MySQL2mysql-8.0.18-winx64in>mysql -h localhost -u root -P 3307 -p
    Enter password: ************
    Welcome to the MySQL monitor.  Commands end with ; or g.
    Your MySQL connection id is 8
    Server version: 8.0.18
    
    Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved.
    
    Oracle is a registered trademark of Oracle Corporation and/or its
    affiliates. Other names may be trademarks of their respective
    owners.
    
    Type 'help;' or 'h' for help. Type 'c' to clear the current input statement.
    
    mysql> alter user 'root'@'localhost' identified with mysql_native_password by '123456';
    Query OK, 0 rows affected (0.01 sec)
    
    mysql> flush privileges;
    Query OK, 0 rows affected (0.00 sec)
    
    mysql> use mysql;
    Database changed
    mysql> create user 'root'@'%' identified by '123456';
    Query OK, 0 rows affected (0.00 sec)
    
    mysql> grant all on *.* to 'root'@'%';
    Query OK, 0 rows affected (0.00 sec)
    
    mysql> alter user 'root'@'%' identified with mysql_native_password by '123456';
    Query OK, 0 rows affected (0.00 sec)
    
    mysql> flush privileges;
    Query OK, 0 rows affected (0.00 sec)
    
    mysql>
    

    MySQL3安装步骤

    D:ProgrammingMySQL8MySQL3mysql-8.0.18-winx64in>mysqld --defaults-file=D:ProgrammingMySQL8MySQL3mysql-8.0.18-winx64my.ini --initialize --console
    2019-11-06T13:22:41.619497Z 0 [System] [MY-013169] [Server] D:ProgrammingMySQL8MySQL3mysql-8.0.18-winx64inmysqld.exe (mysqld 8.0.18) initializing of server in progress as process 3956
    2019-11-06T13:22:44.022580Z 5 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: dF-++?wor5oH
    
    D:ProgrammingMySQL8MySQL3mysql-8.0.18-winx64in>mysqld --install MySQL3 --defaults-file=D:ProgrammingMySQL8MySQL3mysql-8.0.18-winx64my.ini
    Service successfully installed.
    
    D:ProgrammingMySQL8MySQL3mysql-8.0.18-winx64in>net start mysql3
    MySQL3 服务正在启动 .
    MySQL3 服务已经启动成功。
    
    
    D:ProgrammingMySQL8MySQL3mysql-8.0.18-winx64in>mysql -h localhost -u root -P 3308 -p
    Enter password: ************
    Welcome to the MySQL monitor.  Commands end with ; or g.
    Your MySQL connection id is 8
    Server version: 8.0.18
    
    Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved.
    
    Oracle is a registered trademark of Oracle Corporation and/or its
    affiliates. Other names may be trademarks of their respective
    owners.
    
    Type 'help;' or 'h' for help. Type 'c' to clear the current input statement.
    
    mysql> alter user 'root'@'localhost' identified with mysql_native_password by '123456';
    Query OK, 0 rows affected (0.00 sec)
    
    mysql> flush privileges;
    Query OK, 0 rows affected (0.00 sec)
    
    mysql> use mysql;
    Database changed
    mysql> create user 'root'@'%' identified by '123456';
    Query OK, 0 rows affected (0.00 sec)
    
    mysql> grant all on *.* to 'root'@'%';
    Query OK, 0 rows affected (0.01 sec)
    
    mysql> alter user 'root'@'%' identified with mysql_native_password by '123456';
    Query OK, 0 rows affected (0.00 sec)
    
    mysql> flush privileges;
    Query OK, 0 rows affected (0.00 sec)
    
    mysql>
    
  • 相关阅读:
    Mesos 配置项解析
    1039. Course List for Student (25)
    Cts框架解析(12)-ITargetPreparer
    通过ulimit改善linux系统性能(摘自IBM)
    HDU 1080 DP
    C语言调用Lua函数
    创建MySQL从库
    C# Func<>托付
    SpringMVC入门
    VNC连接Ubuntu 16.04桌面灰色的问题解决
  • 原文地址:https://www.cnblogs.com/hgnulb/p/9606268.html
Copyright © 2011-2022 走看看