Our features site is undergoing a refresh! Be sure to explore the revamped site and discover our latest product roadmap launching here on Monday, March 18th.

I need to change root password without restarting MySQL Server

Shyamasundar Bhat shared this idea 2 years ago
Needs Review

We wanted to randomly change MySQL passwords on our cPanel servers, however, we noticed that, MySQL was being restarted after root password is reset using whmapi1 call. Here is commands run and output:

[root@sql-ser:/root]$ whmapi1 set_local_mysql_root_password password="some-password"
---
data:
configs_updated: 1
password_reset: 1
profile_updated: 1
metadata:
command: set_local_mysql_root_password
reason: OK
result: 1
version: 1
[root@sql-ser:/root]$
[root@sql-ser:/root]$ cat /root/.my.cnf
[client]
password="some-password"
user=root
[root@sql-ser:/root]$ 
[root@sql-ser:/root]$ mysqladmin version | grep Uptime
Uptime: 32 sec
[root@sql-ser:/root]$ 
I would like to be able to update mysql root user passwords via whmapi1 set_local_mysql_root_password periodically WITHOUT RESTARTING MYSQL SERVER.  


Note: All MySQL servers are localhost and not remote (at least if you can do this).

Replies (1)

photo
1

Hey there! The API call assumes the existing root password is not known, and follows the steps outlined here:

https://dev.mysql.com/doc/refman/8.0/en/resetting-permissions.html

Per the MySQL documentation, you can use a standard ALTER USER statement to update the password, even for root, without it initiating a restart.

I still think this is a valid request, so I'll see if the API call can have a flag added to avoid the restart. Thanks!

Leave a Comment
 
Attach a file