Resetting root password in Ubuntu server is very easy, There are two ways to reset your administrative root password or there are two situations.
When you Lost your Ubuntu Server password: When this happen do nothing, just go to your Cloud service provider (like Digitalocean, hetzner, linode, vultr) dashboard, In Digitalocean Select server go Access menu and click on Reset root password. In hetzner select the server and go to Rescue menu then click on Reset root password. You will get the same option in Linode and Vultr too.
When you Have the password but you want to set your own password: In this you case you don't want to use system generated password. You wanted to change system generated password to your own. Then just login to your server Terminal and follow the bellow steps.
In above case if you forget your MySQL root password which is also used to login into MySQL database through PhpMyadmin then try this method : Lost Mysql password or Got Locked