方法1: 用SET PASSWORD命令mysql
mysql -u rootsql
mysql> SET PASSWORD FOR 'root'@'localhost' = PASSWORD('newpass');數據庫
方法2:用mysqladminssh
mysqladmin -u root password "newpass"ide
方法3: 用UPDATE直接編輯user表ip
mysql -u roottable
mysql> use mysql;登錄
mysql> UPDATE user SET Password = PASSWORD('newpass') WHERE user = 'root';密碼
mysql> FLUSH PRIVILEGES;方法
在丟失root密碼的時候,能夠這樣
mysqld_safe --skip-grant-tables&
mysql -u root mysql
mysql> UPDATE user SET password=PASSWORD("new password") WHERE user='root';
mysql> FLUSH PRIVILEGES;
數據庫設置鏈接ssh登陸
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'wwwshopsysimei654jsb123' WITH GRANT OPTION;flush privileges; 便可
或
用root用戶登錄,而後:
grant all privileges on *.* to 建立的用戶名 @"%" identified by "密碼";
flush privileges; * 刷新剛纔的內容*