There are certain illnesses which are associated with violence, or have aggression as a symptom (which will not always result in physical violence). Especially the Cluster B personality disorders come to mind, with narcissistic rage and crimes perpetrated by people with antisocial personality disorder. Oppositional defiant disorder in children also includes aggression, as well as some addictions like alcoholism.
But these are only a few of the existing mental conditions. Basically, any single system in a human's brain can be messed up, including the ones responsible for aggression. The handful of conditions in which this happens is only a small percentage of all possible conditions. It is not that different from non-mental illness: there are hundreds of diagnoses, but only a small part of them are connected to a specific organ, say, the liver. Most people who suffer from a physical condition do not have a messed up liver; similarly, most people who suffer from a mental condition don't have a messed up aggression control.
If you are concerned with public safety, then it is quite possible that better methods for diagnosing and treating the aggression related mental conditions will result in a society with less violent crime. For example, this study found that 35% of a random sample of prison inmates has antisocial personality disorder, and goes on to mention that it is especially common in violent offenders, while I've seen numbers for the general population estimated at between 1 and 5% (sorry, no citation on that currently present, maybe somebody has better data). So if we knew how to heal people with APD, we could expect less violence in society, as they contribute so much to it.
But if you are concerned with your own personal safety, I would not recommend avoiding people who appear to have a mental illness. The conditions which have the most visible symptoms - the Down child with a creepy smile, the autistic boy who repeatedly jerks his head - are not the ones which are usually connected to aggression. The (potentially aggressive) people with cluster B disorders I mentioned above are hard to diagnose even for specialists, and appear outwardly normal at first. If you are dealing with somebody who has them, you are likely to notice a proneness to aggression which strikes you as unusually high long before you have even thought that this person could have a mental illness. And with some of them, you might not be aware of their condition even after spending years in a close familial relationship with them. So, you cannot use their condition as a heuristic to avoid them, because you are not aware of it at all. If you are on the street and see somebody who reminds you of a caricatural media portrayal of "mentally ill", the risk that he is prone to aggression is not that much higher than that of the normally looking passerbys.
If an acquaintance shares with you that they have a mental illness diagnosis, there is no reason to panic either. Research the specific illness they have so you can better understand it and support them in living with it, for most mental conditions you are not taking any risk for yourself in doing so. And if it is one of the few conditions where they can be violent, the research should easily uncover that, so you can make an informed decision.