若是忘記mysql的root密碼能夠採起下面的步驟從新設置mysql
1。kill掉全部mysql的進程sql
2。使用--skip-grant-tables的參數啓動mysqlshell
shell> mysqld_safe --skip-grant-tables &server
3。設置新的密碼,一樣兩種方式能夠選擇進程
方法一ip
shell> mysqladmin -u root flush-privileges password "newpwd"table
方法二密碼
mysql> UPDATE mysql.user SET Password=PASSWORD('newpwd')方法
-> WHERE User='root';word
mysql> FLUSH PRIVILEGES;
4。中止mysql server,用正常的模式啓動
5。OK,能夠使用新設置的密碼了