Mysql mistakenly deletes root user or forgets root password solution _mysql
Source: Internet
Author: User
Workaround One:
To other MySQL-installed servers (if you want to know the MySQL root password on the server), open the "MySQL installation directory/var/mysql", the user.frm, user. MyD, user. Myi three files are copied to the "MySQL installation directory/var/mysql" directory of the offending server. Then reboot the server.
Workaround Two:
Modify your My.ini or my.cnf file and add the following line to the [mysqld] section
Skip-grant-tables
Then save and restart the MySQL service. Below you can log into the database with any user name password.
(1) If the root user is mistakenly deleted, use the following statement to create the root user:
Insert into user set host= ' localhost ', user= ' root ', Password=password (' 111111 '), 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 ';
(2) If you have forgotten the root password, use the following statement to modify the root password:
Update user set Password=password (' 111111 ') where user= ' root ';
MySQL mistakenly deletes root user
1, the first end of the mysqld process
#killall mysqld into MySQL
#/usr/local/mysql/bin/mysql
Do not load grant_tables and enter MySQL
#mysqld_safe –skip-grant-tables &
mysql> use MySQL
Database changed
Mysql> select * from user;
Empty Set (0.00 sec)
mysql> INSERT INTO user set user= ' root ', ssl_cipher= ', x509_issuer= ", x509_subject=";
(Add root user's table)
Query OK, 1 row affected, 3 warnings (0.00 sec)
(You may be prompted to have a field such as Ssl_cipher without a default value, just add, ssl_cipher= "; If prompted to add the field, click OK)
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 ';
(This is the right to modify the root user)
Mysql> quit;
2, with the right to start MySQL normal
#service mysqld Start
3, use the root user login (if there is a phpadmin directly with the root blank password login and then modify the password or permissions on it)
#mysql-U root-p
mysql> Update user Set Password=password (' 123456′) where user= ' root ';
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.