Mysql ERROR 1045 (28000) in ubuntu: how to solve the problem of Access denied for user root @ localhost, ubuntu28000

Source: Internet
Author: User

Mysql ERROR 1045 (28000) in ubuntu: how to solve the problem of Access denied for user root @ localhost, ubuntu28000

Method 1:

Skip-grant-tables: very useful mysql startup parameters

This section describes a very useful mysql startup parameter -- skip-grant-tables. As the name implies
Grant-tables is not enabled for mysql. What is the purpose? Of course, it is useful when you forget the administrator password.

Start mysql with command line parameters: #/usr/bin/mysqld_safe -- skip-grant-tables &

3. Modify the administrator password:

Use mysql;

Update user set password = password ('yournewpasswordhere ') where user = 'root'; flush privileges; exit;

4. Kill mysql and restart mysql.

Then you can log on directly.

Method 2:

View the mysql installation path

Then we change the password of the root user,

View default password first

Then log on directly.

Then change the root default user name and password.

Grant all privileges on *. * to 'root' @ 'localhost' identified by 'Password'; flush privileges;

Mysql> update mysql. user set password = password ('new password') where User = "test" and Host = "localhost ";

Mysql> flush privileges;

Mysql> delete from user where User = 'root' and Host = 'localhost ';

Mysql> flush privileges;

Mysql> grant select, delete, update, create, drop on *. * to test @ "%" identified by "1234 ";

Mysql> UPDATE user SET Host = '2017. 0.0.1 'WHERE User = 'root' AND Host = 'localhost ';

Mysql> flush privileges;

Modify Grant_priv to 'y' (flush privileges; (execute this statement or restart MySQL to take effect) and update mysql. user set Grant_priv = 'y' where user = 'ptmind ';

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.