hj_mysql5.7.36免安裝版


官網下載地址 -> https://dev.mysql.com/downloads/mysql/    選擇 Windows (x86, 64-bit), ZIP Archive;

解壓文件->配置系統環境變量到bin目錄. 系統變量:  MY_SQL57_HOME  D:\SYS\ISP\mysql-5.7.36-winx64   Path: %MY_SQL57_HOME\bin

如果電腦缺乏 msvcr120.dll等倆文件,去Microsoft官網(https://www.microsoft.com/zh-cn/download/confirmation.aspx?id=40784)

單機手動下載,有三個.exe文件. 下載 執行;

新建my.ini文件,內容如下.放置到解壓后與 bin平級的目錄下.

[mysql]
# 設置mysql客戶端默認字符集
default-character-set=utf8 
[mysqld]
# 服務端使用的字符集默認為8比特編碼的latin1字符集
character-set-server=utf8
#設置3308端口 默認是3306
port=3308 
# 設置mysql的安裝目錄
basedir="D:\SYS\ISP\mysql-5.7.36-winx64"
# 設置mysql數據庫的數據的存放目錄
datadir="D:\SYS\ISP\mysql-5.7.36-winx64\data"
# 設置mysql數據庫的數據存放臨時文件目錄
tmpdir="D:\SYS\ISP\mysql-5.7.36-winx64\data"
log-error="D:\SYS\ISP\mysql-5.7.36-winx64\data\mysql57_error.log"
# 設置mysql的socket目錄
socket="D:\SYS\ISP\mysql-5.7.36-winx64\data\mysql.sock"
# 允許最大連接數
max_connections=200
# 創建新表時將使用的默認存儲引擎
default-storage-engine=INNODB
# 其他先使用默認配置咯~ 

以管理員的身份運行cmd,切入到bin目錄下---->

1->mysqld --initialize -insecure --user=hj_mysql  創建data目錄,服務命名為 hj_mysql ;

     ps:mysqld --initialize -insecure 這個命令會生成無密碼的root用戶,而命令 mysqld --initialize自動生成帶隨機密碼的root用戶

2->mysqld --install hj_mysql --defaults-file="D:\SYS\ISP\mysql-5.7.36-winx64\my.ini" 

若報錯: The service already exists! 需要執行以下操作,然后徹底干掉mysql殘留文件,注冊表. 然后再執行安裝

D:\SYS\ISP\mysql-5.7.36-winx64\bin>sc query mysql    查詢mysql服務 mysql/hj_mysql 服務名

SERVICE_NAME: mysql
        TYPE               : 10  WIN32_OWN_PROCESS
        STATE              : 1  STOPPED
        WIN32_EXIT_CODE    : 0  (0x0)
        SERVICE_EXIT_CODE  : 0  (0x0)
        CHECKPOINT         : 0x0
        WAIT_HINT          : 0x0

D:\SYS\ISP\mysql-5.7.36-winx64\bin>sc delete mysql 刪除服務
[SC] DeleteService 成功

D:\SYS\ISP\mysql-5.7.36-winx64\bin>mysqld -install hj_mysql --defaults-file="D:\SYS\ISP\mysql-5.7.36-winx64\bin\my.ini"
Service successfully installed.

 ps: 若是報錯 mysql57 服務正在啟動 . mysql57 服務無法啟動。 服務沒有報告任何錯誤。

  可運行 mysqld --console 命令.根據里面信息再排錯,或者查看mysql57_error.log日志...

例如:Can't open and lock privilege tables: Table 'mysql.user' doesn't exist 等,若是這個錯,刪除掉data目錄,

   執行 mysqld --initialize --user=hj_mysql --console 重新生成data文件. 

3->啟動服務 net strat hj_mysql  mysql -uroot -p 進入.若老是報錯ERROR 2003 (HY000): Can't connect to MySQL server on 'localhost' (10061),

    請千萬主意是不是沒帶端口號...如果改了默認端口的話..  net strat hj_mysql  -> mysql -uroot -P3308 -p

   也可用免密方式進入再置空密碼,流程如下;

  net stop hj_mysql 停止服務 ,然后運行 mysqld --console --skip-grant-tables --shared-memory 如下顯示:

D:\SYS\ISP\mysql-5.7.36-winx64\bin>net stop hj_mysql
hj_mysql 服務正在停止.
hj_mysql 服務已成功停止。

D:\SYS\ISP\mysql-5.7.36-winx64\bin>mysqld --console --skip-grant-tables --shared-memory
2021-12-07T09:07:54.182983Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2021-12-07T09:07:54.183042Z 0 [Note] --secure-file-priv is set to NULL. Operations related to importing and exporting data are disabled
2021-12-07T09:07:54.183571Z 0 [Note] mysqld (mysqld 5.7.36) starting as process 6380 ...
2021-12-07T09:07:54.187450Z 0 [Note] InnoDB: Mutexes and rw_locks use Windows interlocked functions
2021-12-07T09:07:54.188386Z 0 [Note] InnoDB: Uses event mutexes
2021-12-07T09:07:54.188801Z 0 [Note] InnoDB: _mm_lfence() and _mm_sfence() are used for memory barrier
2021-12-07T09:07:54.189158Z 0 [Note] InnoDB: Compressed tables use zlib 1.2.11
2021-12-07T09:07:54.189461Z 0 [Note] InnoDB: Number of pools: 1
2021-12-07T09:07:54.189757Z 0 [Note] InnoDB: Not using CPU crc32 instructions
2021-12-07T09:07:54.191818Z 0 [Note] InnoDB: Initializing buffer pool, total size = 128M, instances = 1, chunk size = 128M
2021-12-07T09:07:54.196132Z 0 [Note] InnoDB: Completed initialization of buffer pool
2021-12-07T09:07:54.240463Z 0 [Note] InnoDB: Highest supported file format is Barracuda.
2021-12-07T09:07:54.271125Z 0 [Note] InnoDB: Creating shared tablespace for temporary tables
2021-12-07T09:07:54.271694Z 0 [Note] InnoDB: Setting file '.\ibtmp1' size to 12 MB. Physically writing the file full; Please wait ...
2021-12-07T09:07:54.279638Z 0 [Note] InnoDB: File '.\ibtmp1' size is now 12 MB.
2021-12-07T09:07:54.280919Z 0 [Note] InnoDB: 96 redo rollback segment(s) found. 96 redo rollback segment(s) are active.
2021-12-07T09:07:54.281177Z 0 [Note] InnoDB: 32 non-redo rollback segment(s) are active.
2021-12-07T09:07:54.281740Z 0 [Note] InnoDB: Waiting for purge to start

  再另開一個cmd窗口---> mysql -uroot -p 無密碼直接回車(這可不帶端口號).

D:\SYS\ISP\mysql-5.7.36-winx64\bin>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.36 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> use mysql
Database changed
mysql>

 密碼置空:  mysql -u root -p 直接回車進入. use mysql  update user set authentication_string='' where user='root';  flush privileges; exit;

D:\SYS\ISP\mysql-5.7.36-winx64\bin>mysql -u root -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 3
Server version: 5.7.36 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>
mysql> ;
ERROR:
No query specified

mysql> update user set authentication_string='' where user='root';
ERROR 1046 (3D000): No database selected
mysql> use mysql
Database changed
mysql> update user set authentication_string='' where user='root';
Query OK, 1 row affected (0.00 sec)
Rows matched: 1  Changed: 1  Warnings: 0

mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
mysql> exit;
Bye

關閉免密模式的cmd窗口.啟動服務 net start hj_mysql mysql -uroot -p   

修改密碼 alter user 'root'@'localhost' identified with mysql_native_password by '123456';

flush privileges; exit;

mysql> alter user 'root'@'localhost' identified with mysql_native_password by '123456';
Query OK, 0 rows affected (0.00 sec)

mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)

mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| sys                |
+--------------------+
4 rows in set (0.00 sec)

mysql>          ps:mysql cmd下若語句寫錯一直->這樣,可 Ctrl+c 同時按退出那錯誤語句.

 大功告成~ 

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM