mysql5.7 壓縮包方式安裝步驟

安裝包 mysql5.7

1、管理員cmd下刪除服務 sc delete mysql 

2、在bin同級目錄新建data文件夾和 my.ini

3、編輯my.ini


[mysql]
# 設置mysql客戶端默認字符集
default-character-set=utf8 
[mysqld]
#設置3306端口
port = 3306 
# 設置mysql的安裝目錄
basedir=D:\mysql-5.7.20-winx64
# 設置mysql數據庫的數據的存放目錄
datadir=D:\mysql-5.7.20-winx64\data
# 允許最大連接數
max_connections=200
# 服務端使用的字符集默認爲8比特編碼的latin1字符集
character-set-server=utf8
# 創建新表時將使用的默認存儲引擎
default-storage-engine=INNODB

explicit_defaults_for_timestamp=1

sql_mode=STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION

//在my.ini中這個默認打開,等修改密碼過後再註釋
#skip_grant_tables


4、初始化

mysqld --initialize --user=mysql --console

5、安裝服務

bin 路徑下 安裝服務 mysqld install MySQL --defaults-file="D:\mysql-5.7.20-winx64\my.ini"

6、在執行修改密碼時候如果有報1290的錯誤

//在my.ini中這個默認打開,等修改密碼過後再註釋
#skip_grant_tables

root 密碼爲空的時候配置文件中下面這句:

skip-grant-tables
GRANT ALL PRIVILEGES ON *.* TO IDENTIFIED BY '123' WITH GRANT OPTION;

執行這句時候錯誤:

ERROR 1290 (HY000): The MySQL server is running with the --skip-grant-tables option so it cannot execute this statement
mysql> GRANT ALL PRIVILEGES ON *.* TO IDENTIFIED BY '123' WITH GRANT OPTION;
ERROR 1290 (HY000): The MySQL server is running with the --skip-grant-tables option so it cannot execute this statement
這個時候我們只需要

flush privileges

7、默認初始密碼是空

>mysql -u root -p

進入mysql命令行後,使用下面命令,設置密碼
   SET PASSWORD = PASSWORD('新密碼');
       修改密碼:set password for root@localhost = password('123456');

      5.6方式
      update mysql.user set password=PASSWORD('123456') where User='root';

       5.7方式
       update mysql.user set authentication_string=PASSWORD('123456') where User='root';

 

 

在mysql中user表中修改數據


8、mysql服務啓動與停止

輸入"net start mysql"啓動mysql,
輸入"net stop mysql"停止mysql服務

9、授權並創建新用戶

grant all on *.* to root@'%' identified by 'password';

 

發佈了7 篇原創文章 · 獲贊 11 · 訪問量 3萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章