if you are talking about mysql connectivity on a linux or unix platform, then your database is not publically accessible through the HTTP protocol (someone can't just type in a link and download your database).
you provide your host name, username, password and database name, nowhere do you provide a URL unless using a remote database.
your mysql database details stored in a php script are completely safe from being read from anyone other than you, the server administrators and anyone else who has access to that file through the backend. people can't simply go view source in their browser and see your database password if you store it in a php variable, as php is a server side language and is processed before anything is sent to your browser.
you can set higher security levels and settings on your webserver and/or mysql server, but with most set ups, it is perfectly safe anyway and doesn't need to be safer. your passwords
should be stored in hashed form in your database anyway, so even if someone did get in, they would only see a bunch of nonsense instead of a password.
if you are really paranoid about your database security or feel as if your content requires a higher level of security than what mysql databases generally offer, you may want to try using an
Oracle database instead.