Mysql deletes root users by mistake. mysql deletes root users by mistake.

Source: Internet
Author: User
Tags mysql flush privileges

Mysql deletes root users by mistake. mysql deletes root users by mistake.

The root account is accidentally deleted when some default accounts are cleared after the database is installed. The new root account after the flush privileges forgets to grant any permissions. Check that the mysqld option contains an −skip-grant-tables

Copy codeThe Code is as follows:
#/Usr/libexec/mysqld -- verbos -- help

The mysql5.5 manual is described as follows:

Copy codeThe Code is as follows:
-- Skip-grant-tables

This option causes the server to start without using the privilege system at all, which gives anyone with access to the server unrestricted access to all databases. you can cause a running server to start using the grant tables again by executing mysqladmin flush-privileges or mysqladmin reload command from a system shell, or by issuing a MySQL flush privileges statement after connecting to the server. this option also suppresses loading of plugins, user-defined functions (UDFs), and scheduled events. to cause plugins to be loaded anyway, use the -- plugin-load option.

-- Skip-grant-tables is unavailable if MySQL was configured with the -- disable-grant-options option. See Section 2.10.2, "Typical configure Options ".

Mysqld_safe is a STARTUP script for MySQL servers in Unix/Linux systems. This script adds some security features. It will continue to monitor the running status of the MySQL server after it is started, and restart the server when an error occurs. Start mysql in the background

Copy codeThe Code is as follows:
# Mysqld_safe -- skip-grant-tables &

Add

Copy codeThe Code is as follows:
Insert into user SET User = 'root', Host = 'localhost', ssl_cipher = '', x509_issuer ='', x509_subject = '';

Directly enter mysql connection and add permissions. At this time, the grant command cannot be used, and only the update command can be used.

Copy codeThe Code is as follows:
UPDATE user SET Select_priv = 'y', Insert_priv = 'y', Update_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', Alter_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', Event_priv = 'y', Trigger_priv = 'y', Create_tablespace_priv = 'y ', authentication_string = ''WHERE User = 'root ';

Note that mysql 5.5 is used, and SQL statements or other places may be different during the operation. After the statement is executed, flush privileges is required, and you may need to log on again.

Related Article

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.