reset MySQL root password

Forgot your password for MySQL? This is one of those things that only happens in spite of the many precautions we can take. As a result, you’re out of your database server. You can not create new databases, and continues with little control over the state of the database server. In situations such as root access to your database server. So what can you do to change the password for the root user in MySQL for Windows and Linux.
Users of Windows:
Log in to your server as an administrator. Kill MySQL-server, if it is running. This implies that the Windows Service Manager, click Start, click Control Panel, then Administrative Tools and select Services. Search here and stop the MySQL-server. If it does not exist, and that MySQL is working until means that MySQL is not running as a service. In this case it is necessary to start Task Manager, you can use Ctrl + Alt + Del is now to kill MySQL process.

The process is stopped MySQL you need to change passwords in MySQL with the combination of the options for updating and FLUSH. Thus, the introduction to your favorite text editor and create a new file. Enter the following text in the file, which has replaced “NewMySQLPassword” to a new password:

UPDATE mysql.user SET Password=PASSWORD(”NewMySQLPassword”) WHERE User=’root’;
FLUSH PRIVILEGES;

What does the first line is to update the values in the “Password” in the table mysql.user for the user “root” to “NewMySQLPassword. In the second line of the old dumps a series of rights and guarantees that your new password in the world. Save as C: \ mysql_reset.txt.

Then you need MySQL-server for the configuration file as a parameter. Start the terminal, click Start, then Run and type CMD and press “Enter.” Now enter the following command:

C:\mysql\bin\mysqld-nt –init-file=C:\mysql_reset.txt

After the server starts, delete the file C: \ mysql_reset.txt. Your password for MySQL now reboot. Now restart the MySQL server again. Return to the Windows Services manager to do so again. Your new password for MySQL should work for you.

Linux users:
Log on to your computer as root. Measures relating to the restoration of MySQL password for the root MySQL server to restart without active permits for access to MySQL as root without a password, set a new password, and then restart normally. Proceed to the next. First, stop the server MySQL:

# /etc/init.d/mysql stop

Now start MySQL server with skip-grant-tables option, which is a server without the permission of:

# mysqld_safe –skip-grant-tables &

The last option is the command and act as a background process. Now connect to your MySQL server as root:

# Mysql-u root

If, without a password. The following steps will be the new password:

mysql> use mysql;
mysql> update user set password=PASSWORD(”NewMySQLPassword”) where User=’root’;
mysql> flush privileges;
mysql> quit

Replace “NewMySQLPassword” for your password. This is what happened here. The first line selects the configuration of MySQL tables. The second line updates the value of field “Password” for user “root” to “NewMySQLPassword. The third line of the old dumps a series of rights and guarantees that your new password in the world. Well, the last step is to restart the server normally and use the your new password to access:

# /etc/init.d/mysql stop
# /etc/init.d/mysql start
# mysql -u root -pNewMySQLPassword

Congratulations, your new root MySQL password, and set up your MySQL-server is ready to work again. Do not forget, all your applications to use this password if you are in the world.






Leave a Reply