1 zip文件解壓到目錄 D:Alantop_Diralantop_sdeMySQL-8.0.27
2 在mysql-8.0.27目錄下建立my.ini文件
[mysqld]
default_authentication_plugin=mysql_native_password
# Remove leading # and set to the amount of RAM for the most important data
# cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%.
# innodb_buffer_pool_size = 128M
# Remove leading # to turn on a very important data integrity option: logging
# changes to the binary log between backups.
# log_bin
# These are commonly set, remove the # and set as required.
basedir = "D:\alantop_dir\alantop_sde\mysql-8.0.27"
datadir = "D:\alantop_dir\alantop_sde\mysql-8.0.27\Data"
port = 3306
# server_id = .....
# Remove leading # to set options mainly useful for reporting servers.
# The server defaults are faster for transactions and fast SELECTs.
# Adjust sizes as needed, experiment to find the optimal values.
# join_buffer_size = 128M
# sort_buffer_size = 2M
# read_rnd_buffer_size = 2M
#sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
#sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
character-set-server = utf8mb4
performance_schema_max_table_instances = 600
table_definition_cache = 400
table_open_cache = 256
[mysql]
default-character-set = utf8mb4
[client]
default-character-set = utf8mb4
3 mysql初始化數據庫和默認密碼
mysqld --initialize --console
注意:鍵入上面命令后,控制臺上會顯示默認密碼,如果沒記住,可以從data文件中日志文件err中查詢。
4 安裝啟動mysql服務
mysqld --install mysql
net start mysql
5 用heidisql登錄,第一次登錄會提示修改默認密碼。
6 查看修改用戶加密方式
select host,user,plugin from mysql.user;
ALTER USER 'test1'@'localhost' IDENTIFIED WITH mysql_native_password BY '123';
FLUSH PRIVILEGES;
如果此處修改了密碼認證方式,my.ini中的
default_authentication_plugin=mysql_native_password
這句可以刪除掉。
采用mysql_native_password認證方式主要是兼容有些程序的密碼認證方式。