window環(huán)境安裝mysql5.7.21,具體內(nèi)容如下
1. 從MySQL官網(wǎng)下載免安裝的壓縮包mysql-5.7.21-winx64.zip
2. 解壓到相應的目錄(此處解壓到F:\mysql-5.7.21-winx64)
3. 配置環(huán)境變量,將MySQL的啟動目錄(F:\mysql-5.7.21-winx64\bin)添加到Path中
4. 在MySQL目錄下(F:\mysql-5.7.21-winx64)創(chuàng)建my.ini文件,內(nèi)容如下:
[mysql] # 設置mysql客戶端默認字符集 default-character-set=utf8 [mysqld] #設置3306端口 port = 3306 # 設置mysql的安裝目錄 basedir=F:\mysql-5.7.21-winx64 # 設置mysql數(shù)據(jù)庫的數(shù)據(jù)的存放目錄 datadir=F:\mysql-5.7.21-winx64\data # 允許最大連接數(shù) max_connections=200 # 服務端使用的字符集默認為8比特編碼的latin1字符集 character-set-server=utf8 # 創(chuàng)建新表時將使用的默認存儲引擎 default-storage-engine=INNODB
5. 管理員身份運行cmd
切換目錄:C:\Windows\system32>cd F:\mysql-5.7.21-winx64\bin
生成MySQL服務:
F:\mysql-5.7.21-winx64\bin>mysqld -install Service successfully installed.
生成data目錄:F:\mysql-5.7.21-winx64\bin>mysqld --initialize-insecure --user=mysql
啟動MySQL服務:
C:\Windows\system32>net start mysql MySQL 服務正在啟動 . MySQL 服務已經(jīng)啟動成功。
6. 登錄數(shù)據(jù)庫,修改密碼(默認密碼為空)
登錄數(shù)據(jù)庫:
C:\Windows\system32>mysql -uroot -p Enter password: Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 2 Server version: 5.7.21 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>
修改密碼:
mysql> mysql> mysql> show databases; +--------------------+ | Database | +--------------------+ | information_schema | | mysql | | performance_schema | | sys | +--------------------+ 4 rows in set (0.00 sec) mysql> use mysql; Database changed mysql> update user set authentication_string=password("新密碼") where User="root"; Query OK, 1 row affected, 1 warning (0.00 sec) Rows matched: 1 Changed: 1 Warnings: 1 mysql> mysql>FLUSH PRIVILEGES;
精彩專題分享:mysql不同版本安裝教程 mysql5.7各版本安裝教程
以上就是本文的全部內(nèi)容,希望對大家的學習有所幫助,也希望大家多多支持腳本之家。