1. 程式人生 > >linux上mysql忘記密碼

linux上mysql忘記密碼

一、更改配置檔案,跳過密碼登入
    vim /etc/my.cnf
    [mysql]
    skip-grant-tables

    重啟mysql

二、空密碼進入資料庫,更改使用者密碼
    不用密碼直接進入資料庫,再更改使用者密碼
    use mysql;update user set password=password('123456') where user='root' and host='localhost';flush privileges;

三、註釋跳過密碼
    vim /etc/my.cnf
    [mysql]
    #skip-grant-tables
    
    重啟mysql