mysql數(shù)據(jù)庫的root賬號(hào)被誤刪除了如何添加
1.打開mysql.ini文件在mysqld下面添加skip-grant-tables后重啟mysql數(shù)據(jù)庫.
2. 直接執(zhí)行mysql命令進(jìn)入數(shù)據(jù)庫
MariaDB [mysql]> insert into mysql.user set user='root'; 插入一個(gè)賬號(hào)(執(zhí)行下面命令,設(shè)置root用戶的權(quán)限,所有權(quán)限為 ' y ' ,即擁有最高權(quán)限。)
MariaDB [mysql]> update user set Host='localhost',select_priv='y', insert_priv='y',
update_priv='y',Alter_priv='y',delete_priv='y',create_priv='y',drop_priv='y',
reload_priv='y',shutdown_priv='y',Process_priv='y',file_priv='y',grant_priv='y',
References_priv='y',index_priv='y',create_user_priv='y',show_db_priv='y',
super_priv='y',create_tmp_table_priv='y',Lock_tables_priv='y',execute_priv='y',
repl_slave_priv='y',repl_client_priv='y',create_view_priv='y',show_view_priv='y',
create_routine_priv='y',alter_routine_priv='y',create_user_priv='y' where user='root';

4.退出后重啟mysql數(shù)據(jù)庫執(zhí)行mysql –uroot –p 直接回車進(jìn)入數(shù)據(jù)庫設(shè)置root密碼
MariaDB [(none)]> update mysql.user set password=password('1234567') where user=
'root';
MariaDB [(none)]> flush privileges;
MariaDB [(none)]> exit

5.去掉my.ini中的skip-grant-tables后重啟數(shù)據(jù)庫就可以使root賬號(hào)進(jìn)入mysql數(shù)據(jù)庫了