To set a password you may use the command line as well
sudo teamviewer passwd [password]
When you run TeamViewer on a device the ID will be the same. TeamViewer should not be opened by a virtual terminal like TightVNC, because it will not be able to grab the video as expected. That's the reason we suggest you restart the service to be able to run TeamViewer again without issues.
Hope this solution works for you. Don't hesitate to ask if you have extra questions or comments.
Did my reply answer your question? Accept it as a solution to help others, Thanks.