mysql安裝及改端口 mysql 8.0.19 安裝 及 端口修改

mysql 8.0.19 安裝 及 端口修改

1.創建my.ini文件

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# For advice on how to change settings please see
# http://dev.mysql.com/doc/refman/5.6/en/server-configuration-defaults.html
# *** DO NOT EDIT THIS FILE. It's a template which will be copied to the
# *** default location during install, and will be replaced if you
# *** upgrade to a newer version of MySQL.
[mysqld]
# 設置3309端口
port=3309   #根據自己的需要修改端口
# 設置mysql的安裝目錄
basedir=L:\1_mysql\mysql-8.0.19-winx64 #根據自己的文件位置修改
# 設置mysql數據庫的數據的存放目錄
datadir=L:\1_mysql\mysql-8.0.19-winx64\Data #根據自己的文件位置修改
# 允許最大連接數
max_connections=200
# 允許連接失敗的次數。這是爲了防止有人從該主機試圖攻擊數據庫系統
max_connect_errors=10
# 服務端使用的字符集默認爲UTF8
character-set-server=utf8
# 創建新表時將使用的默認存儲引擎
default-storage-engine=INNODB
# 默認使用“mysql_native_password”插件認證
default_authentication_plugin=mysql_native_password
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=utf8
[client]
# 設置mysql客戶端連接服務端時默認使用的端口
port=3309   #根據自己的需要修改端口
default-character-set=utf8

2.解壓mysql-8.0.19-winx64.zip到安裝目錄;
3.將my.ini文件複製到mysql-8.0.19-winx64根目錄;
4.進入mysql-8.0.19-winx64\bin文件夾,在此文件夾下打開Powershell窗口;
5.安裝mysql,
輸入:
mysqld --install
返回:
Service successfully installed.
6.初始化mysql,
輸入:
mysqld --initialize --console
返回:
2020-05-21T01:51:15.619733Z 0 [System] [MY-013169] [Server] L:\1_mysql\mysql-8.0.19-winx64\bin\mysqld.exe (mysqld 8.0.19) initializing of server in progress as process 328
2020-05-21T01:51:15.622433Z 0 [Warning] [MY-013242] [Server] --character-set-server: 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous.
2020-05-21T01:51:30.165449Z 5 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: e-%Uh<=ga1qp
7.啓動mysql,
輸入:
net start mysql
回顯:
MySQL 服務正在啓動 ..
MySQL 服務已經啓動成功。
8.登錄mysql,
輸入:
mysql -u root -p
回顯:
Enter password: "輸入密碼"
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 8
Server version: 8.0.19

Copyright (c) 2000, 2020, 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.

9.修改密碼:
輸入:
ALTER user 'root'@'localhost' IDENTIFIED BY '新密碼';
回顯:
Query OK, 0 rows affected (0.34 sec)
10.查看端口號:
輸入:
show global variables like 'port';
回顯:
+---------------+-------+
| Variable_name | Value |
+---------------+-------+
| port | 3309 |
+---------------+-------+
1 row in set, 1 warning (0.01 sec)


11.其它操作
停止mysql服務:

net stop mysql

刪除mysql:

mysqld -remove mysql
刪除服務:

sc delete mysql

查詢user表,看host和user情況

select user,host from user;

修改MySQL登錄主機名稱(所有主機):

update user set host = '%' where user = 'root';

刷新MySQL的系統權限相關表:

flush privileges; 

切換使用的數據庫:

use mysql 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章