win10下mysql8解壓版(mysql-8.0.15)安裝

win10下mysql8解壓版(mysql-8.0.15)安裝html

https://dev.mysql.com/doc/refman/8.0/en/data-directory-initialization.htmlmysql

電腦之前安裝了mysql5.5 並安裝成服務sql

下載mysql-8.0.15解壓並放到須要安裝的位置,如圖數據庫

新建文件my.ini, 內容以下:bash

#D:\Program Files\mysql-8.0.15-winx64
#D:\Program Files\mysql-8.0.15-winx64\my.ini
#D:\Program Files\mysql-8.0.15-winx64\data

# 數據庫服務端配置項
[mysqld]
# 數據庫路徑
basedir=D:\\Program Files\\mysql-8.0.15-winx64
# 數據路徑
datadir=D:\\Program Files\\mysql-8.0.15-winx64\\data
# 端口號
port=3307
# 默認字符集
character-set-server=utf8mb4
# 存儲引擎
default-storage-engine=INNODB
# 默認使用「mysql_native_password」插件認證
default_authentication_plugin=mysql_native_password
# 容許最大鏈接數
#max_connections=200
# 容許鏈接失敗的次數。這是爲了防止有人從該主機試圖攻擊數據庫系統
#max_connect_errors=10


# 客戶端配置項
[mysql]
# 默認字符集
default-character-set=utf8mb4

# 鏈接客戶端配置項
[client]
default-character-set=utf8mb4

3 到mysql8安裝目錄,已管理員身份運行 (命令行提示符cmd)ide

這裏有3種方法,選則其中一個就好。插件

第一種是沒有指定my.ini 配置文件的,使用 --initialize ,默認會使用mysql安裝目錄下的咱們的建立的my.ini 啓用--initialize 會建立密碼命令行

mysqld  --initialize --console       #mysql8初始化
mysqld --install mysql8        #mysql8安裝成服務,服務名爲mysql8
mysqld --remove mysql8        #卸載mysql8服務名的服務

第二種是指定my.ini 配置文件,須要把指定文件參數放第一位參數,使用 --initialize。   啓用--initialize 會建立密碼code

mysqld --defaults-file="D:\\Program Files\\mysql-8.0.15-winx64\\my.ini" --initialize --console 
mysqld --defaults-file="D:\\Program Files\\mysql-8.0.15-winx64\\my.ini" --install mysql8

第三種是使用 --initialize-insecure。   啓用--initialize-insecure 不會建立密碼,她能夠結合指定初始化文件使用,也能夠不指定初始化文件。server

if you used --initialize-insecure to initialize the data directory, connect to the server as root without a password:
mysql -u root --skip-password
mysqld --initialize-insecure
mysqld --install mysql8
net start mysql8

 

應爲之前安裝過mysql的其它版本,且也安裝成服務的,這個mysql安裝成服務後,這個mysql8的服務可能所指的程序不對,須要修改。

運行註冊表 regedit

計算機\HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\MySQL

計算機\HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\mysql8

之前安裝的MySQL的服務的路徑

新安裝的mysql8的路徑,特別說明下,不光能夠修改路徑,還能夠把配置文件都寫在這裏,根據需求來。

都啓動一下,如圖

 

運行結果:

mysql5.5  端口是 3306

mysql-8.0.15  端口是 3307

 

若是是使用的--initialize-insecure 不會生成密碼,使用

mysql --port 3307 -uroot --skip-password        #登錄
ALTER USER 'root'@'localhost' IDENTIFIED BY 'root-password';     #設置密碼
flush privileges;        #刷新權限

使用新密碼登錄便可,如圖。

 

本身安裝下和之前5.7的解壓版安裝沒有什麼變化。

 

create database tmall charset=utf8mb4  COLLATE utf8mb4_general_ci;
create database tmall default charset=utf8mb4  COLLATE utf8mb4_general_ci;

drop database tmall;

create database tspboot default charset=utf8mb4  COLLATE utf8mb4_general_ci;

----如下N條在mysql8中無效----
grant all privileges on tmall.* to `tmall`@`localhost` identified by 'tmall';
grant all privileges on tmall.* to `tmall`@`%` identified by 'tmall';
revoke all privileges on tmall.* from `tmall`@`localhost`;
revoke all privileges on tmall.* from `tmall`@`%`;
grant all privileges on *.* to `dxw`@`%` identified by 'dxw';
----以上N條在mysql8中無效----



create user `tmall`@'localhost' identified by 'tmall';
grant all privileges on tmall.* to 'tmall'@'localhost';
flush privileges;


REVOKE all privileges  ON tmall.* FROM `tmall`@`localhost`;
DROP USER `tmall`@`localhost`;
flush privileges;



create database elfinder default charset=utf8mb4  COLLATE utf8mb4_general_ci;

create database paofen default charset=utf8mb4  COLLATE utf8mb4_general_ci;

create user `root`@'%' identified by 'root__';
grant all privileges on *.* to 'root'@'%';
flush privileges;

create user `root`@'192.168.31.148' identified by 'root__';
grant all privileges on *.* to 'root'@'192.168.31.148';
flush privileges;
相關文章
相關標籤/搜索