Ubuntu server installed MySQL database forgot password resolution method

Source: Internet
Author: User
Tags administrator password

Client connection times wrong MySQL database appears: Error1045 Errors, indicates that the user name or password entered is denied access.

The solution can be divided into the following steps:

1. Modify the MySQL configuration file so that you can login MySQL without password

sudo vim/etc/mysql/my.cnf

Add under [mysqld]

Skip-grant-tables

2. Restart the MySQL service

sudo service MySQL restart

3. No password login MySQL

Mysql-uroot-p

4. Modify the Administrator password

Use MySQL;

Update user set Password=password (' 123 ') where user= ' root ';

Flush privileges;

Exit

5. Restore the configuration file

6. You can log in using the following command

Mysql-uroot-p123

2003-can ' t connect to MySQL server on ' x.x.x.x ' (10038)

MySQL service is no problem:

    1. [Email protected]:~$ ps-ef|grep mysqld
    2. MySQL 1219 1 0 21:09? 00:00:01/usr/sbin/mysqld
    3. Sean 10373 9602 0 21:38 pts/7 00:00:00 grep--color=auto mysqld

And the local login can also succeed:

  1. [Email protected]:~$ mysql-u root-h 127.0.0.1
  2. Welcome to the MySQL Monitor. Commands End With; or \g.
  3. Your MySQL Connection ID is 40
  4. Server version:5.5.47-0ubuntu0.14.04.1 (Ubuntu)
  5. Copyright (c), Oracle and/or its affiliates. All rights reserved.
  6. Oracle is a registered trademark of the Oracle Corporation and/or its
  7. Affiliates. Other names trademarks of their respective
  8. Owners.
  9. Type ' help ', ' or ' \h ' for help. Type ' \c ' to clear the current input statement.
  10. Mysql>

However, you cannot log on using an extranet address:

    1. [Email protected]:~$ mysql-u root-h 192.168.137.128
    2. ERROR 2003 (HY000): Can ' t connect to MySQL server on ' 192.168.137.128 ' (111)

So I modified the MySQL configuration file:

    1. [Email protected]:~$ sudo vi/etc/mysql/my.cnf

Add # (Comment out this line) before bind-address= 127.0.0.1 this line

    1. # Instead of skip-networking The default is now-listen only on
    2. # localhost which are more compatible and are not less secure.
    3. #bind-address = 127.0.0.1

Then restart the MySQL service:

    1. [Email protected]:~$ sudo service mysql restart
    2. MySQL stop/waiting
    3. MySQL start/running, process 11622
Error 1130:mysql 1130 effective solution for connection errors
Mysql>  UseMySQL; ReadingTableInformation forCompletion of Table  and columnnames you can turnoffThis feature toGet a quicker startup with -ADatabasechanged MySQL> SelectHostUser, password from User; +-----------+------------------+-------------------------------------------+      |Host| User             |Password|      +-----------+------------------+-------------------------------------------+      |localhost|Root|                                           |      |Sean|Root|                                           |      | 127.0.0.1 |Root|                                           |      |::1       |Root|                                           |      |localhost|Debian-Sys-Maint| *0aa379ab8afd785b32d661a07e9d5c7a24e3b186|      +-----------+------------------+-------------------------------------------+      5Rowsinch Set(0.00sec) MySQL> Update User SetHost="%"whereHost="Sean" and User ="Root"; Query OK,1Row affected (0.00sec) Rows matched:1Changed:1Warnings:0MySQL>FlushPrivileges; Query OK,0Rows Affected (0.00sec) MySQL> SelectHostUser, password from User; +-----------+------------------+-------------------------------------------+      |Host| User             |Password|      +-----------+------------------+-------------------------------------------+      |localhost|Root|                                           |      | %         |Root|                                           |      | 127.0.0.1 |Root|                                           |      |::1       |Root|                                           |      |localhost|Debian-Sys-Maint| *0aa379ab8afd785b32d661a07e9d5c7a24e3b186|      +-----------+------------------+-------------------------------------------+      5Rowsinch Set(0.00Sec

Using Navicat, you can successfully connect to the database.

Ubuntu server installed MySQL database forgot password resolution method

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.