0、獲取安裝包
1、在bin目錄添加My.ini文件,內容如下
[mysql] # 設置mysql客戶端默認字符集 default-character-set=utf8 [mysqld] #設置3306端口 port = 3306 # 設置mysql的安裝目錄 basedir=D:\mysql-5.7.23-win32 # 設置mysql數據庫的數據的存放目錄 datadir=D:\mysql-5.7.23-win32\data # 允許最大連接數 max_connections=200 # 服務端使用的字符集默認為8比特編碼的latin1字符集 character-set-server=utf8 # 創建新表時將使用的默認存儲引擎 default-storage-engine=INNODB
2、安裝和啟動MySQL
#進入根目錄 C:\Windows\System32>d: #進入bin目錄 D:\>cd item\mysql-3306\bin 安裝mysqld服務 D:\item\mysql-3306\bin>mysqld install 運行mysqld D:\item\mysql-3306\bin>mysqld --initialize 啟動mysql D:\item\mysql-3306\bin>net start mysql
3、獲取密碼
在“D:\item\mysql-3306\data”下面找到*.err文件,紅框已經框出默認密碼
(初始化數據庫mysqld –initialize –user=root –console)
3、登陸和設置密碼
D:\item\mysql-3306\bin>mysql -u root -p #登陸 Enter password: ****** #輸入默認密碼 Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 9 Server version: 5.7.23 MySQL Community Server (GPL) Copyright (c) 2000, 2018, 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> SET PASSWORD FOR 'root'@'localhost' = PASSWORD('huanu'); #設置密碼 Query OK, 0 rows affected, 1 warning (0.00 sec) mysql>