MySQL Root Password reset

Source: Internet
Author: User

MySQL Root Password Reset

1 Login failed, mysqladmin change password failed

[Email protected] var]# mysqladmin-u root password ' 123456 '

Mysqladmin:connect to server at ' localhost ' failed

Error: ' Access denied for user ' root ' @ ' localhost ' (using Password:no) '

2 Stop MySQL service

[[email protected] var]#/etc/init.d/mysqld stop

Shutting down MySQL .... success!

3 Safe Mode startup

[Email protected] var]# Mysqld_safe--skip-grant-tables &

4 No password root account login

[Email protected] var]#/usr/bin/mysql–u root-p

"Note, in the following request you enter the password, you do not have to control, the direct key to knock on the past."

Enter Password:

Welcome to the MySQL Monitor. Commands End With; or \g.

Your MySQL Connection ID is 48

Server Version:5.1.41-log Source Distribution

Type ' help ', ' or ' \h ' for help. Type ' \c ' to clear the current input statement.

mysql> use MySQL;

Database changed

5 Manual update Change Password

mysql> Update user Set Password=password ("GUXXXXXAHYVH") where user= ' root ' and host= ' localhost ';

Query OK, 1 row Affected (0.00 sec)

Rows matched:1 changed:1 warnings:0

mysql> flush Privileges;

Query OK, 0 rows Affected (0.00 sec)

Mysql> quit

Bye

[Email protected] var]# mysql–u root–p GUNNHTQHJUNFKY6AHYVH

Welcome to the MySQL Monitor. Commands End With; or \g.

Your MySQL Connection ID is 172

Server Version:5.1.41-log Source Distribution

Type ' help ', ' or ' \h ' for help. Type ' \c ' to clear the current input statement.

Mysql> quit

Bye

6 Normal Restart

[Email protected] var]# service mysqld restart

Shutting down MySQL. 110407 17:45:29 mysqld_safe mysqld from PID File/usr/local/mysql/var//mysql.chinascopefinanical.com.pid ended

success!

Starting MySQL. success!

[1]+ done Mysqld_safe--skip-grant-tables

[Email protected] var]#

7 other forms of error condition analysis

7.1 Unable to find sock error:

[Email protected] mysqld]#/usr/bin/mysql–u root-p

Enter Password:

ERROR 2002 (HY000): Can ' t connect to local MySQL server through socket '/var/lib/mysql/mysql.sock ' (111)

[Email protected] mysqld]#

When you log in, add the sock parameter to OK.

[Email protected] mysqld]#/usr/bin/mysql–u root-p--socket=/opt/mysqldata/mysql.sock

Enter Password:

Welcome to the MySQL Monitor. Commands End With; or \g.

Your MySQL Connection ID is 6

Server version:5.1.69 Source Distribution

7.2 hold wrong [ERROR]/usr/libexec/mysqld:error writing file '/var/run/mysqld/mysqld.pid ' (errcode:28)

130830 10:59:02 innodb:initializing buffer pool, size = 1.0G

130830 10:59:02 innodb:completed initialization of buffer pool

130830 10:59:02 innodb:started; Log sequence number 0 2727887496

130830 10:59:02 [ERROR]/usr/libexec/mysqld:error writing file '/var/run/mysqld/mysqld.pid ' (errcode:28)

130830 10:59:02 [ERROR] Can ' t start server:can ' t create PID file:no space left on device

130830 10:59:02 mysqld_safe Number of processes running now:0

130830 10:59:02 Mysqld_safe mysqld restarted

130830 10:59:02 innodb:initializing buffer pool, size = 1.0G

130830 10:59:02 innodb:completed initialization of buffer pool

130830 10:59:02 innodb:started; Log sequence number 0 2727887496

130830 10:59:02 [ERROR]/usr/libexec/mysqld:error writing file '/var/run/mysqld/mysqld.pid ' (errcode:28)

130830 10:59:02 [ERROR] Can ' t start server:can ' t create PID file:no space left on device

130830 10:59:03 mysqld_safe Number of processes running now:0

130830 10:59:03 Mysqld_safe mysqld restarted

130830 10:59:03 innodb:initializing buffer pool, size = 1.0G

[ analysis]: Can not write to the default PID file, modify the/etc/init.d/mysqld, the PID point to other road warp

[Email protected] mysqld]# Vi/etc/init.d/mysqld

.....

Get_mysql_option mysqld datadir "/var/lib/mysql"

Datadir= "$result"

Get_mysql_option mysqld Socket "$datadir/mysql.sock"

Socketfile= "$result"

Get_mysql_option mysqld_safe log-error "/var/log/mysqld.log"

Errlogfile= "$result"

get_mysql_option mysqld_safe Pid-file "/opt/mysqldata/mysqld.pid" # '/var/run/mysqld/mysqld.pid ' original value, modified here to another path/opt/mysqldata/mysqld.pid

Mypidfile= "$result"

.....

Then start the Mysqld service, OK, success.

This article is from the "Jack" blog, please be sure to keep this source http://396386.blog.51cto.com/386386/1543303

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.