The 'accesssdeniedforuser' root '@ 'localhost' (usingpassword: YES)' of MySQL in Ubuntu is incorrect.

Source: Internet
Author: User
Tags mysql login
Problem description: My environment is apt-get installed mysql under xUbuntu12.10, and cannot be logged on. The error message is as follows: the installation is completed using the command (sudoapt-getinstallmysql-servermysql-client. the mysql service is running. in this case, you need to change the root password, but this often happens. 'accesssdeniedforuser' root' @ 'localhost' (usin

Symptom:
In my environment, I installed mysql with apt-get in xUbuntu 12.10. I cannot log on to mysql. The error message is as follows: sudo apt-get install mysql-server mysql-client) after installation. the mysql service is running. in this case, you need to change the root password, but this often happens. 'Access denied for user' root' @ 'localhost' (using password: YES) 'or other situations that cause logon Failure to mysql.

Solution:
1. Open the/etc/mysql/debian. cnf file, which stores the relevant password. My file information is as follows:

Sudovi/etc/mysql/debian. cnf # Automatically generated for Debian scripts. do not touch!
[Client]
Host = localhost
User = debian-sys-maint
Password = 6x1XG2B5p75WtFV2
Socket =/var/run/mysqld. sock

[Mysql_upgrade]
Host = localhost
User = debian-sys-maint
Password = 6x1XG2B5p75WtFV2
Socket =/var/run/mysqld. sock
Basedir =/usr

There are two lines in the [client] segment: user = and password =. This is how to install mysql through apt-get. The mysql login name and password set by the system for us

2. Enter the following command:
Mysql-udebian-sys-maint-pdebian-sys-maint is debian. content following user = in cnf. after you press enter, you will be prompted to enter the password. copy and paste the content after password = and press enter to start the mysql console.


3. After Entering the console, follow these steps:
Use mysql; update user set password = PASSWORD ('new password') where user = 'root'; flush privileges; you can enter quit; log out and log on with the root account, you can also continue other operations.

Reading:

ERROR 1044 (42000): Access denied for user ''@ 'localhost' to database' mysql http://www.linuxidc.com/Linux/2013-03/81341.htm and http://www.linuxidc.com/Linux/2012-06/63618.htm

ERROR 1045 (28000): Access denied for user 'root' @ 'localhost' (using password: NO) http://www.linuxidc.com/Linux/2012-11/74518.htm

MySQL reports Access denied for user when using lock tables http://www.linuxidc.com/Linux/2012-01/51802.htm without the lock tables permission

Run mysql under gentoo prompt Access denied for user 'root' @ 'localhost' resolution http://www.linuxidc.com/Linux/2007-12/9866.htm Error

For more information about Ubuntu, see Ubuntu special page http://www.linuxidc.com/topicnews.aspx? Tid = 2

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.