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:\Programming\MySQL8\MySQL1\mysql-8.0.18-winx64
# 設置mysql數據庫的數據的存放目錄(mysql-8.0.18不需要手動創建data文件夾)
datadir=D:\Programming\MySQL8\MySQL1\mysql-8.0.18-winx64\data
# 允許最大連接數
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:\Programming\MySQL8\MySQL1\mysql-8.0.18-winx64\my.ini --initialize --console

# 安裝mysql服務
mysqld --install [服務名] MySQL1 --defaults-file=D:\Programming\MySQL8\MySQL1\mysql-8.0.18-winx64\my.ini
mysqld --install MySQL1 --defaults-file=D:\Programming\MySQL8\MySQL1\mysql-8.0.18-winx64\my.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:\Programming\MySQL8\MySQL2\mysql-8.0.18-winx64\bin>mysqld --defaults-file=D:\Programming\MySQL8\MySQL2\mysql-8.0.18-winx64\my.ini --initialize --console
2019-11-06T13:19:04.091682Z 0 [System] [MY-013169] [Server] D:\Programming\MySQL8\MySQL2\mysql-8.0.18-winx64\bin\mysqld.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:\Programming\MySQL8\MySQL2\mysql-8.0.18-winx64\bin>mysqld --install MySQL2 --defaults-file=D:\Programming\MySQL8\MySQL2\mysql-8.0.18-winx64\my.ini
Service successfully installed.

D:\Programming\MySQL8\MySQL2\mysql-8.0.18-winx64\bin>net start mysql2
MySQL2 服務正在啟動 .
MySQL2 服務已經啟動成功。


D:\Programming\MySQL8\MySQL2\mysql-8.0.18-winx64\bin>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:\Programming\MySQL8\MySQL3\mysql-8.0.18-winx64\bin>mysqld --defaults-file=D:\Programming\MySQL8\MySQL3\mysql-8.0.18-winx64\my.ini --initialize --console
2019-11-06T13:22:41.619497Z 0 [System] [MY-013169] [Server] D:\Programming\MySQL8\MySQL3\mysql-8.0.18-winx64\bin\mysqld.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:\Programming\MySQL8\MySQL3\mysql-8.0.18-winx64\bin>mysqld --install MySQL3 --defaults-file=D:\Programming\MySQL8\MySQL3\mysql-8.0.18-winx64\my.ini
Service successfully installed.

D:\Programming\MySQL8\MySQL3\mysql-8.0.18-winx64\bin>net start mysql3
MySQL3 服務正在啟動 .
MySQL3 服務已經啟動成功。


D:\Programming\MySQL8\MySQL3\mysql-8.0.18-winx64\bin>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>


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM