安裝Mysql總是遇到很多的問題
一、安裝包:
安裝包:直接官網下載(https://dev.mysql.com/downloads/windows/installer/),由于之前安裝免安裝壓縮包版本,總是出現各種問題,所以,直接重新下載了一個Mysql install 安裝版本
相關網址:https://www.cnblogs.com/chengxs/p/5986095.html
二、修改密碼:
我去網上看他們說的找到my.ini(這個一個Mysql的配置文件),可我總是怎么找都找不到,于是我就按照網上說的去設置顯示隱藏文件,結果還是看不到my.ini ,于是再去網上找,網上好多個版本,基本都是沒有用的。
原來,要找到my.ini,要先去找到ProgramData,(這里要先打開顯示隱藏文件的設置):
1、編輯點開my.ini文件 ,這是讓Mysql 不用密碼就能登入
.2、先停用此服務:
3、執行命令 mysqld --skip-grant-tables
1)、遇到如下錯誤:
mysqld: Can't change dir to '\Program Files\MySQL\MySQL Server 8.0\data'
2)、解決辦法:
a、由于mysqld –skip-grant-tables實測在mysql8.0中已失效,現使用mysqld --console --skip-grant-tables --shared-memory
b、此外,由于my.ini文件和mysqld文件不在同一個文件夾內,需要指定my.ini文件的位置,通過--defaults-file="C:\ProgramData\MySQL\MySQL Server 8.0\my.ini"
故,命令如下:
mysqld --defaults-file="C:\ProgramData\MySQL\MySQL Server 8.0\my.ini" --console --skip-grant-tables --shared-memory
4、另外開一個cmd,使用 mysql -u root -p
不用管password,直接回車
5、修改root密碼
首先,采用命令:
update user set authentication_string=password("123456") where user="root";
出現以下錯誤:
mysql> update user set authentication_string=password("123456") where user="root";
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that
corresponds to your MySQL server version for the right syntax to use near '("123456") where user="root"' at line 1
mysql>
因此,換一種方式,采用如下命令:
mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY '123456';
Query OK, 0 rows affected (0.13 sec)
可能會出現錯誤:The MySQL server is running with the –skip-grant-tables option so it cannot execute this statement(本人執行時遇到過,所以記錄下來),沒關系,刷新權限,重新執行以上命令即可。
6、刷新權限,命令如下:
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
退出,重新登錄
mysql>exit;