---
name: database-tools-changing-forgotten-mysql-root-password
title: Changing a forgotten MySQL root password
description: 'To change the MySQL root password, use the following steps:'
last-updated: 2017-11-10
---

> ## Documentation Index
> The table of contents for this documentation set is at https://cloud.ibm.com/docs/database-tools?format=markdown
> The index for all IBM Cloud docs is at: https://cloud.ibm.com/docs/llms.txt
> Use these files to discover more information as needed.

# Changing a forgotten MySQL root password
{: #dbt-change-mysql-password}

To change the MySQL root password, use the following steps:

1. Run the following commands:

   ```text
   # /etc/init.d/mysqld stop
   ```
   {: pre}

   ```
   # mysqld_safe --skip-grant-tables --skip-networking
   ```
   {: pre}

2. Connect to MySQL with the following command:

   ```text
   # mysql -u root
   ```
   {: pre}

3. Run the following command in the MySQL client:

   ```text
   # UPDATE mysql.user SET Password=PASSWORD('newpassword') WHERE User='root';
   ```
   {: pre}

4. Replace `newpassword` with your new root password.

5. Restart the MySQL server by using the following command:

   ```text
   # /etc/init.d/mysqld start
   ```
   {: pre}