PHP study 升級默認的MYSQL版本 爲5.7

前言:因爲項目需求,本地開發環境使用了phpstudy 的默認集成環境,可是因爲其自帶的mysql只是5.5的版本。在laravel 應用中顯得尤其不足,並且這段時間須要學習laracms 其自己要求的數據庫就須要達到5.7沒辦法只能升級。看了網上不少的教程和方法,前期老是很好的,可是每次重啓的時候都會報沒法鏈接本地的錯誤。

Can't connect to MySQL server on localhost (10061)

因而只能是慢慢地摸索和找方法,終於找到了解決方式,併爲此記錄下來。分享給有須要的朋友。


1.備份原來的MySQL文件夾phpstudy\PHPTutorial\MySQL重命名爲MySQL5.5 2.將下載的mysql5.7壓縮文件解壓縮,並放在phpstudy\PHPTutorial\文件夾下,命名爲MySQL; 3.將目錄下的my-default.ini修改成my.ini (這裏本人嘗試過把原有的ini文件直接放進去,可是在啓動的時候就是不停地報錯。)

我設置的my.ini,有須要的能夠直接粘貼複製使用,後期請自行從新根據各自的項目進行從新配置php

# For advice on how to change settings please see
# http://dev.mysql.com/doc/refman/5.7/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:/phpstudy/PHPTutorial/MySQL/"
datadir="D:/phpstudy/PHPTutorial/MySQL/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 
#skip-grant-tables
sql-mode="NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION"
max_connections=512
explicit_defaults_for_timestamp=true
複製代碼

4.以管理員身份運行cmd進入phpstudy\PHPTutorial\MySQL\bin目錄;

運行 mysqld --install #此命令用於安裝mysql運行後顯示:Service successfully installed複製代碼

5.運行 mysqld --initialize --user=root --console

運行後顯示:
2018-11-26T05:30:06.207044Z 0 [Warning] InnoDB: New log files created, LSN=45790
2018-11-26T05:30:06.310050Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.
2018-11-26T05:30:06.340052Z 0 [Warning] No existing UUID has been found, so we assume that this is the first time that this server has been started. Generating a new UUID: 5524df0e-f13c-11e8-8811-1c6f65e86efe.
2018-11-26T05:30:06.343052Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
2018-11-26T05:30:06.359053Z 1 [Note] A temporary password is generated for root@localhost: :5OVJr5WO<Ws複製代碼

其中(:5OVJr5WO<Ws)爲新生成的隨機密碼html

此時使用「net start mysql」成功啓動msyql複製代碼

net start mysql
MySQL 服務正在啓動 .
MySQL 服務已經啓動成功。
複製代碼

登陸成功後能夠經過隨機的帳號密碼對數據庫進行登陸mysql

mysql -u root -p
Enter password: (輸入生成的隨機密碼)

#登陸後從新修改密碼
set password=password('123456');

#到此在phpstudy下從新升級mysql完成

最後記得刪除以前老的mysql版本
mysqld -remove
而後再phpstudy中從新安裝服務就能夠了複製代碼
相關文章
相關標籤/搜索