本文記錄了mysql 5.7.21安裝配置方法,具體內容如下
1.下載
下載地址
解壓到自己喜歡的一個位置即可(目錄中不要包含中文)
如:D:/Program Files/
2.系統環境變量配置
(1)新增系統變量
變量名:MYSQL_HOME
變量值:Mysql解壓目錄,如D:/Program Files/mysql-5.7.21-winx64
(2)追加PATH
;%MYSQL_HOME%/bin;
3.配置my.ini文件
在解壓根目錄新建一個my.ini的文件
# For advice on how to change settings please see# http://dev.mysql.com/doc/refman/5.6/en/server-configuration-defaults.html# *** DO NOT EDIT THIS FILE. It's a template which will be copied to the# *** default location during install, and will be replaced if you# *** upgrade to a newer version of MySQL. [mysqld] # 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://Program Files/mysql-5.7.21-winx64" datadir = "D://Program Files/mysql-5.7.21-winx64/data" port = 3306 character_set_server = utf8 # 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
4.管理員方式啟動命令提示窗符
進入mysql解壓目錄到bin目錄下
如:D:/Program Files/mysql-5.7.21-winx64/bin
分別執行:
(1)初始化:mysqld -initialize-insecure
如果報錯failed to set datadir to 則 執行一下 mysqld --initialize --user=mysql --console,再執行(1);
正確之后會在Mysql解壓根目錄生成data文件夾以及相關文件
(2)mysqld -install
*如提示Install/Remove of the Service Denied,說明不是已管理員的方式進入的命令提示符
(3)啟動服務:net start mysql
(4)登陸,改密碼 mysql -u root -p
【成功登陸的直接到(5)】
我的出現了
在my.ini中增加
重啟服務,成功登陸
(5)執行改密碼語句 (正常登陸的使用set password= password(‘新密碼'); )
update user set authentication_string = password("新密碼") where user='root';
(6)exit; net stop mysql
(7)登陸成功的忽略這一步
到my.ini中注釋掉
重啟進入之后set password= password(‘新密碼');
到此就可以正常使用了。
(8)測試 show databases;
5.寫兩個bat文件用于啟動和關閉mysql服務
(1)啟動mysql服務
@echo offecho 確定要啟動MySQL服務嗎?pausenet start mysqlecho 啟動MySQL服務完成,請確認有沒有錯誤發生。Pause
保存為 mysql服務啟動.bat 文件,運行時要以管理員方式運行
(2)關閉mysql服務
@echo offecho 確定要關閉MySQL服務嗎?pausenet stop mysqlecho 關閉MySQL服務完成,請確認有沒有錯誤發生。Pause
保存為 mysql服務關閉.bat 文件,運行時要以管理員方式運行
MySql到此安裝結束。
以上就是本文的全部內容,希望對大家的學習有所幫助,也希望大家多多支持VeVb武林網。
新聞熱點
疑難解答