一、MySQL的下載
下載地址:https://dev.mysql.com/downloads/mysql/
?下載的文件:
二、MySQL安裝和配置
?解壓,zip格式解壓縮之后其實MySQL就可以使用了,但是要進行環(huán)境變量配置
我的電腦->屬性->高級系統(tǒng)設(shè)置->環(huán)境變量,選擇Path,在其后面添加: 你的mysql bin文件夾的路徑 :D:installmysql-8.0.26-winx64in
?配置完環(huán)境變量之后,在D:installmysql-8.0.26-winx64目錄下新增加一個配置文件my.ini ,同時在bin的同級目錄下創(chuàng)建一個data文件夾(用于存放數(shù)據(jù)庫數(shù)據(jù))
[client] # 設(shè)置mysql客戶端默認(rèn)字符集 default-character-set=utf8 [mysqld] # 設(shè)置3306端口 port = 3306 # 設(shè)置mysql的安裝目錄 basedir=D:installmysql-8.0.26-winx64 # 設(shè)置 mysql數(shù)據(jù)庫的數(shù)據(jù)的存放目錄,MySQL 8+ 不需要以下配置,系統(tǒng)自己生成即可,否則有可能報錯 datadir=D:installmysql-8.0.26-winx64data # 允許最大連接數(shù) max_connections=200 # 服務(wù)端使用的字符集默認(rèn)為8比特編碼的latin1字符集 character-set-server=utf8 # 創(chuàng)建新表時將使用的默認(rèn)存儲引擎 default-storage-engine=INNODB
?以管理員身份打開 cmd 命令行工具,即我們在Windows10系統(tǒng)的搜索框中直接輸入命令CMD。在命令提示符上單擊右鍵,選擇管理員身份運行。切換目錄:D:installmysql-8.0.26-winx64in
初始化數(shù)據(jù)庫:
mysqld --initialize --console
執(zhí)行完成后,會輸出 root 用戶的初始默認(rèn)密碼,如:
D:installmysql-8.0.26-winx64in>mysqld --initialize --console 2021-10-03T15:13:48.329496Z 0 [System] [MY-013169] [Server] D:installmysql-8.0.26-winx64inmysqld.exe (mysqld 8.0.26) initializing of server in progress as process 5380 2021-10-03T15:13:48.330236Z 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. 2021-10-03T15:13:48.412807Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started. 2021-10-03T15:13:48.905376Z 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended. 2021-10-03T15:13:49.965476Z 0 [Warning] [MY-013746] [Server] A deprecated TLS version TLSv1 is enabled for channel mysql_main 2021-10-03T15:13:49.966392Z 0 [Warning] [MY-013746] [Server] A deprecated TLS version TLSv1.1 is enabled for channel mysql_main 2021-10-03T15:13:50.060809Z 6 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: MPs)*UFna2dw
MPs)*UFna2dw就是初始密碼,后續(xù)登錄需要用到,你也可以在登陸后修改密碼。
輸入以下安裝命令:
mysqld install
啟動輸入以下命令即可:
net start mysql
結(jié)果如下:
D:installmysql-8.0.26-winx64in>mysqld install Service successfully installed. D:installmysql-8.0.26-winx64in>net start mysql MySQL 服務(wù)正在啟動 . MySQL 服務(wù)已經(jīng)啟動成功。 D:installmysql-8.0.26-winx64in>
?修改密碼:alter user user() identified by '密碼';
mysql> alter user user() identified by '123456'; Query OK, 0 rows affected (0.02 sec)
在cmd中訪問MySQL服務(wù):
C:Usersmiracle>mysql -u root -p Enter password: ****** Welcome to the MySQL monitor. Commands end with ; or g. Your MySQL connection id is 12 Server version: 8.0.26 MySQL Community Server - GPL Copyright (c) 2000, 2021, Oracle and/or its affiliates. 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> show databases; +--------------------+ | Database | +--------------------+ | information_schema | | mysql | | performance_schema | | sys | +--------------------+ 4 rows in set (0.02 sec) mysql>
?
本文摘自 :https://www.cnblogs.com/