If you have installed packages on your Ubuntu server, you can list them all with this command
sudo apt list --installed
But if your Ubuntu version is smaller then you should use this command
sudo dpkg --get-selections | grep -v deinstall
You can also filter
sudo dpkg --get-selections | grep -v deinstall | grep mysql
Or you can also use the command
sudo dpkg -l
You can also filter, for example to get all php packages
sudo dpkg -l | grep php
I hope this helps.