不卸載原有mysql直接安裝mysql8.0
下載zip安裝包
下載地址:https://dev.mysql.com/downloads/mysql/
下載完成后,解壓壓縮包,進入壓縮的目錄,新建文本文件my.ini。
假設(shè)你解壓出來的目錄為E:\Program Files\mysql-8.0.19-winx64,my.ini內(nèi)容如下:
[mysqld] # 設(shè)置3306端口 port=3306 # 設(shè)置mysql的安裝目錄 basedir=E:\Program Files\mysql-8.0.19-winx64 # 設(shè)置mysql數(shù)據(jù)庫的數(shù)據(jù)的存放目錄 datadir=E:\Program Files\mysql-8.0.19-winx64\data # 允許最大連接數(shù) max_connections=200 # 允許連接失敗的次數(shù)。這是為了防止有人從該主機試圖攻擊數(shù)據(jù)庫系統(tǒng) max_connect_errors=10 # 服務(wù)端使用的字符集默認為UTF8 character-set-server=UTF8MB4 # 創(chuàng)建新表時將使用的默認存儲引擎 default-storage-engine=INNODB # 默認使用“mysql_native_password”插件認證 default_authentication_plugin=mysql_native_password [mysql] # 設(shè)置mysql客戶端默認字符集 default-character-set=UTF8MB4 [client] # 設(shè)置mysql客戶端連接服務(wù)端時默認使用的端口 port=3306 default-character-set=UTF8MB4
初始化數(shù)據(jù)庫
在MySQL安裝目錄的bin目錄執(zhí)行命令:
mysqld --initialize --console
此時,我的win7系統(tǒng)報錯:
解決方案:去百度下載一個vcruntime140_1.dll放入%windir%\system32\目錄中。
我使用的下載地址:http://www.dbjr.com.cn/dll/vcruntime140_1.dll.html
%windir%\system32\在我的系統(tǒng)中表示C:\Windows\System32
再次執(zhí)行上述命令后:
E:\Program Files\mysql-8.0.19-winx64\bin>mysqld --initialize --console
2020-06-06T16:34:34.062007Z 0 [System] [MY-013169] [Server] E:\Program Files\mys
ql-8.0.19-winx64\bin\mysqld.exe (mysqld 8.0.19) initializing of server in progre
ss as process 7816
2020-06-06T16:34:37.513202Z 5 [Note] [MY-010454] [Server] A temporary password i
s generated for root@localhost: /rfMQ+bGi22z
表示初始化成功。
注意:我這里生成的臨時密碼是/rfMQ+bGi22z,下文會使用到。
登陸mysql數(shù)據(jù)庫
啟動mysql服務(wù)端,需要另外啟動一個命令后,執(zhí)行mysqld:
E:\Program Files\mysql-8.0.19-winx64\bin>mysqld
就如上圖一樣,讓這個命令行一直后臺掛著,mysql的服務(wù)進程占用著它,不能關(guān)閉,關(guān)閉后mysql的服務(wù)進程也會跟著被關(guān)閉。
再用mysql客戶端登陸后,順利登陸:
E:\Program Files\mysql-8.0.19-winx64\bin>mysql -uroot -p/rfMQ+bGi22z mysql: [Warning] Using a password on the command line interface can be insecure. Welcome to the MySQL monitor. ?Commands end with ; or \g. Your MySQL connection id is 8 Server version: 8.0.19 Copyright (c) 2000, 2020, 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>
修改密碼為123456:
mysql> ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '1 23456'; Query OK, 0 rows affected (0.01 sec) mysql>
注冊/刪除mysql服務(wù)
經(jīng)過上述操作mysql8.0已經(jīng)可以正常使用,但啟動mysql服務(wù)需要占用一個命令行未免有些麻煩,現(xiàn)在我們通過將mysqld注冊為系統(tǒng)服務(wù)解決這個問題。
在MySQL安裝目錄的bin目錄執(zhí)行命令:
E:\Program Files\mysql-8.0.19-winx64\bin>mysqld --install mysql8.0 Service successfully installed.
mysql8.0可以改為其他你喜歡的服務(wù)的名字。
注冊成功后,任務(wù)管理器上可以看到服務(wù)的名字:
只需要右鍵啟動服務(wù),mysql8.0就可以正常使用了。
然后mysql客戶端就可以使用新密碼正常的登陸了:
E:\Program Files\mysql-8.0.19-winx64\bin>mysql -uroot -p123456 mysql: [Warning] Using a password on the command line interface can be insecure. Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 10 Server version: 8.0.19 MySQL Community Server - GPL Copyright (c) 2000, 2020, 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>
如果你希望在任何目錄下都能執(zhí)行mysql客戶端命令,則需要將mysql的安裝目錄下的bin目錄加入環(huán)境變量中,例如:E:\Program Files\mysql-8.0.19-winx64\bin。
刪除服務(wù):
sc delete mysql8.0 -remove
mysql8.0是你要刪除的服務(wù)名稱
到此這篇關(guān)于不卸載原有mysql直接安裝mysql8.0的文章就介紹到這了,更多相關(guān)安裝mysql8.0內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!
相關(guān)文章
MySQL?中如何歸檔數(shù)據(jù)的實現(xiàn)方法
本文主要介紹了MySQL?中如何歸檔數(shù)據(jù)的實現(xiàn)方法,文中通過示例代碼介紹的非常詳細,具有一定的參考價值,感興趣的小伙伴們可以參考一下2022-03-03一文學(xué)會Mysql數(shù)據(jù)庫備份與恢復(fù)
數(shù)據(jù)庫備份是在數(shù)據(jù)丟失的情況下能及時恢復(fù)重要數(shù)據(jù),防止數(shù)據(jù)丟失的一種重要手段,下面這篇文章主要給大家介紹了關(guān)于Mysql數(shù)據(jù)庫備份與恢復(fù)的相關(guān)資料,需要的朋友可以參考下2022-05-05