Centos 安裝MySQL可以參考之前寫的一篇文章
Centos7.3 安裝Mysql5.7并修改初始密碼
windows安裝mysql5.7有兩種方式
1、下載.msi安裝文件直接根據(jù)界面提示進(jìn)行安裝
2、下載.biz壓縮包
這里接介紹的是第二種壓縮版的安裝方式
官方的參考文檔 https://dev.mysql.com/doc/refman/5.7/en/windows-install-archive.html
1、下載mysql
其他版本下載地址
https://dev.mysql.com/downloads/mysql/
2、安裝mysql
壓縮包相當(dāng)于免安裝文件,要想使用它只需要配置相關(guān)的參數(shù),再通過(guò)通過(guò)服務(wù)來(lái)啟動(dòng)數(shù)據(jù)庫(kù)服務(wù)就可以了。
2.1 把壓縮包解壓到你喜歡的位置
本示例解壓到:D:/software/mysql-5.7.18-winx64 文件夾下
2.2 創(chuàng)建my.ini文件
mysql-5.7.18-winx64根目錄中創(chuàng)建my.ini文件添加以下內(nèi)容:
[mysqld]# set basedir to your installation pathbasedir=D://software//mysql-5.7.18-winx64# set datadir to the location of your data directorydatadir=D://software//mysql-5.7.18-winx64//dataport = 3306max_allowed_packet = 32M
注意,basedir和datadir是必須要配置的,basedir就是你解壓的目錄
2.3 配置環(huán)境變量
添加一個(gè)名叫 MYSQL_HOME 的變量。
修改Path變量,在末尾添加 %MYSQL_HOME%/bin
2.4 初始化數(shù)據(jù)庫(kù)文件
1、以管理員身份運(yùn)行cmd,進(jìn)入mysql的bin目錄。
2、初始化數(shù)據(jù)庫(kù)文件
mysqld --initialize
初始化成功后,會(huì)在datadir目錄下生成一些文件,其中,xxx.err(xxx是你電腦用戶的名稱)文件里說(shuō)明了root賬戶的臨時(shí)密碼。例子:<r8j*Qrh)jdp就是root賬戶的臨時(shí)密碼
2017-05-17T10:31:54.235041Z 1 [Note] A temporary password is generated for root@localhost: <r8j*Qrh)jdp
2.5 注冊(cè)mysql服務(wù)
mysqld -install MySQL
2.6 啟動(dòng)mysql服務(wù)
net start MySQL
3、修改root密碼
使用root賬號(hào)登錄
mysql -u root -p <r8j*Qrh)jdp
修改root密碼
ALTER USER 'root'@'localhost' IDENTIFIED BY 'new_password';
4、安裝日志
Microsoft Windows [版本 6.3.9600](c) 2013 Microsoft Corporation。保留所有權(quán)利。D:/software/mysql-5.7.18-winx64/bin>mysqld --initializeD:/software/mysql-5.7.18-winx64/bin>D:/software/mysql-5.7.18-winx64/bin>mysqld -install MySQLD:/software/mysql-5.7.18-winx64/bin>net start MySQLMySQL 服務(wù)正在啟動(dòng) ....MySQL 服務(wù)已經(jīng)啟動(dòng)成功。D:/software/mysql-5.7.18-winx64/bin>mysql -uroot -pEnter password: ************Welcome to the MySQL monitor. Commands end with ; or /g.Your MySQL connection id is 3Server version: 5.7.18Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.Oracle is a registered trademark of Oracle Corporation and/or itsaffiliates. Other names may be trademarks of their respectiveowners.Type 'help;' or '/h' for help. Type '/c' to clear the current input statement.mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'root';Query OK, 0 rows affected (0.00 sec)mysql> exitBye
以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持VeVb武林網(wǎng)。
新聞熱點(diǎn)
疑難解答
圖片精選