[Email protected] ~]# VI/ETC/MY.CNF [mysqld]skip-grant-tables
[[Email protected] ~]# service mysqld restartshutting down MySQL ... success! Starting MySQL. success!
mysql> INSERT INTO User (User,password,host) values (' Root ', ' ', ' localhost ');mysql> update user set host= ' localhost ', 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 ', 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 '; Query OK, 1 row affected (0.05 sec) Rows matched:1 changed:1 warnings:0[[email protected] ~]# grep skip/etc/my.c NF #skip-grant-tablesskip-external-locking#skip-networkingslave-skip-errors = all[[email protected] ~]# Service mysqld restartshutting down MySQL. success! Starting MySQL. success! [[email protected] ~]# mysqlwelcome to the MySQL Monitor. Commands enD with; or \g.your MySQL connection ID is 3Server version:5.5.40-log mysql Community Server (GPL) Copyright (c) +, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or itsaffiliates. Other names trademarks of their respectiveowners. Type ' help ', ' or ' \h ' for help. Type ' \c ' to clear the current input statement.mysql> show databases;+--------------------+| Database |+--------------------+| Information_schema | | MySQL | | Performance_schema | | Test |+--------------------+4 rows in Set (0.05 sec) mysql>
mysql> Update User set Password=password ("123") where host= ' localhost '; Query OK, 1 row Affected (0.00 sec) Rows matched:1 changed:1 warnings:0mysql> flush privileges; Query OK, 0 rows Affected (0.00 sec)
[Email protected] ~]# mysql-uroot-p123welcome to the MySQL monitor.
MySQL root user is deleted