Whenever using MSSQL on Home windows I had been accustomed to a really convenient feature known as integrated authentication. In a nutshell, being authenticated in Home windows can provide you with accessibility database, so you don't need to give any sort of password. Now i'm developing a credit card applicatoin on Linux without any user interaction this application must access a mysql database because of its own reasons, so how do you allow it to login? I've discovered that despite the fact that automatically a root account is produced in mysql, this root account doesn't have reference to unix root, I'm able to utilize it even when I'm not a superuser in Linux, and also the password is blank. Obviously I can produce a devoted user account in mysql for the requirements of my application, however in this situation I have to hard-code the password somewhere, which isn't nice. Once more - there's no user interaction during my application, so absolutely no way for somebody to go in the password. I've got a distinct feeling that i'm missing something important here. Thank you for any advice!

First, you should set your password around the mysql root account...

Second, yeah, you are virtually going to need to place the password somewhere, unless of course you place in the application account to utilize a blank password too...

Place the the configurations inside a .my.cnf file:


You should use different config files while using --defaults-file option

More information on option files at dev.mysql.com

You are able to hard-code the password, which, while you say, isn't particularly nice. E.g. in PHP:

 $connection = mysql_connect('HOSTNAME', 'USERNAME', 'PASSWORD')
   or die('Could not connect: ' . mysql_error());

 mysql_select_db('DATABASE') or die('Could not select database');

Alternatively, you can load the password in from the config file, by which situation you can store it in encoded form, but when someone can easily see your source-code and find out the way you decrypt it, they'll have the ability to decrypt it too.