答建設(shè)網(wǎng)站上海牛巨仁seo
一、打開(kāi)MySQL目錄下的my.ini文件,在文件的[mysqld]下面添加一行 skip-grant-tables,保存并關(guān)閉文件;
skip-grant-tables :跳過(guò)密碼登錄,登錄時(shí)無(wú)需密碼。
my.ini :一般在和bin同目錄下,如果沒(méi)有的話可自己創(chuàng)建
自己創(chuàng)建如要注意兩點(diǎn):1、basedir=改成自己的mysql路徑
2、datadir=改成自己存放數(shù)據(jù)路徑
[mysqld]
#skip-grant-tables
# 設(shè)置3306端口
port=3306
# 設(shè)置mysql的安裝目錄 ---這里輸入你安裝的文件路徑----
basedir=D:\mysql-5.7.40-winx64
# 設(shè)置mysql數(shù)據(jù)庫(kù)的數(shù)據(jù)的存放目錄
datadir=D:\mysql\data
# 允許最大連接數(shù)
max_connections=200
# 允許連接失敗的次數(shù)。
max_connect_errors=10
# 服務(wù)端使用的字符集默認(rèn)為utf8
character-set-server=utf8
# 創(chuàng)建新表時(shí)將使用的默認(rèn)存儲(chǔ)引擎
default-storage-engine=INNODB
# 默認(rèn)使用“mysql_native_password”插件認(rèn)證
#mysql_native_password
default_authentication_plugin=mysql_native_password
[mysql]
# 設(shè)置mysql客戶端默認(rèn)字符集
default-character-set=utf8
[client]
# 設(shè)置mysql客戶端連接服務(wù)端時(shí)默認(rèn)使用的端口
port=3306
default-character-set=utf8
二、重啟mysql服務(wù)
net start mysql 開(kāi)啟服務(wù)
net stop mysql 停止服務(wù)
三、通過(guò)cmd行進(jìn)入MySQL的bin目錄,輸入“mysql -u root -p”(不輸入密碼),回車即可進(jìn)入數(shù)據(jù)庫(kù);
四、更改密碼
update mysql.user set authentication_string=password('123456') where user='root' and Host = 'localhost';
五、打開(kāi)MySQL目錄下的my.ini文件,刪除最后一行的“skip-grant-tables”,保存并關(guān)閉文件;
六、執(zhí)行命令,更新緩存
mysql>flush privileges;
mysql>quit;