MySQL database localhost's root user login encountered failure

Source: Internet
Author: User
Tags unique id

Issue:Access denied for user ' root ' @ ' localhost ' (using Password:yes)

Open the MySQL directory under the My.ini file (Linux is/etc/my.cnf), add a line at the end of the file "Skip-grant-tables", save and close the file.
2. Restart the MySQL service.
3, enter "Mysql-uroot-p" in the command line (do not enter a password), enter the database.
4, execute, "use MySQL;" Use the MySQL database.
5. Execute, "Update user set Password=password (" Rootadmin ") where user= ' root '; (Change the root password)
(During the period I also select the record in the user table, query all the time shows some garbled, and then I only query the user table in the host, user, password field, it seems to show 3 records, there are 1 No name.) Of course, in order to solve the problem, I can not control it. )
6. Open the My.ini file in MySQL directory, delete the last line "Skip-grant-tables", save and close the file.
7. Restart the MySQL service.
8, enter "Mysql-uroot-prootadmin" in the command line, the problem is done.
MY.CNF samples such as the next

# Example MySQL config file for medium systems.##-a system with little memory (32m-64m) where MySQL plays# a n important part, or systems up to 128M where MySQL was used together with# other programs (such as a Web server) # # MySQL P Rograms look for option files in a set of# locations which depend on the deployment platform.# you can copy this option fi Le to one of those# locations. For information about these locations, see:# http://dev.mysql.com/doc/mysql/en/option-files.html## in this file, you can u Se All long options This a program supports.# If you want to know which options a program supports and run the program# with             The "--help" option.# the following options would be passed to all MySQL clients[client] #password = Your_passwordport = 3306socket =/tmp/mysql.sock# Here follows entries for some specific programs# the MySQL Server[mys Qld]port = 3306socket =/tmp/mysql.sockskip-external-lockinglog-error=/alidata/log/mysql/error.Logkey_buffer_size = 16mmax_allowed_packet = 1mtable_open_cache = 64sort_buffer_size = 512Knet_buffer_length = 8Kread_ Buffer_size = 256kread_rnd_buffer_size = 512kmyisam_sort_buffer_size = 8m# Don ' t listen on a TCP/IP port at all. This can is a security enhancement,# if all processes then need to connect to mysqld run in the same host.# all Interactio N with Mysqld must is made via Unix sockets or named pipes.# Note that using the this option without enabling named Pipes on W indows# (via the "enable-named-pipe" option) would render mysqld useless!# #skip-networking# Replication Master Server (def Ault) # Binary logging is required for replicationlog-bin=mysql-bin# binary logging format-mixed Recommendedbinlog_format =mixed# required Unique ID between 1 and 2^32-1# defaults to 1 if Master-host isn't set# but would not function as a Mas ter if Omittedserver-id = # Replication Slave (Comment out master sections to use this) # to configure this host as A replication slave, you can choose between# methods: # 1) Use the Change MASTER to command (fully described in our manual)-# the syntax is:## CHAN GE MASTER to Master_host=

  

MySQL database localhost's root user login encountered failure

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.