Click to See Complete Forum and Search --> : Setting user-level environment variables


PhatBarren
11-28-2001, 12:33 AM
Hey...

How can I permanently set a few (new) environment variables at the user-level. I do not have root privileges.

Specifically, I need to set MYSQLDB, MYSQLUSER, and (you guessed it!) MYSQLPASS.

Just for future reference, how would I do this for system-wide environment variables, too?

Thanks :)
PHATBARREN :D

SykkN
11-28-2001, 06:00 AM
Add them to your ~/.bash_profile.

=============================================
.bash_profile
---------------------------------------------

MYSQLDB="something"
MYSQLUSER="something"
MYSQLPASS="something"

export MYSQLDB MYSQLUSER MYSQLPASS

=============================================

SykkN
11-28-2001, 06:02 AM
System wide:

Add the same type of thing to /etc/profile.

PhatBarren
11-28-2001, 09:23 AM
PERFECT!
one question though:

Must I put
'export MYSQLDB MYSQLUSER MYSQLPASS'
right in the .bash_profile file or is that something I must do from a command line after? Is it just to tell the system that you added/changed some environment variables?

THANKS!
jeff

livermoron1
11-28-2001, 12:00 PM
Not positive but if you update the .bash_profile file it should automatically execute when you run a new shell.

After you make the changes to the file either start a new shell (just type bash) or log out and log back in and bash should automatically execute the preferences in the .bash_profile file.

good luck

PLBlaze
11-28-2001, 12:23 PM
For MySQL you could either create a global my.cnf file and put your desired vars there or just for a specific user in their ~/.my.cnf will work too...see www.mysql.com (http://www.mysql.com) for more detais or read mysql docs on your box.

For bash profiles you don't need to logout/login for the changes to update, just run source .bash_profile or whatever file is used.Hope this helps.

PhatBarren
11-28-2001, 01:21 PM
I think the .my.cnf should work for the mysql infos, but I have to have one other variable that is not related to mysql (it's a cookie name). I tried creating a .bash_profile on my server (there wasn't one there already.. i'm surprized) and putting in TESTVAR="testvalue". when i execute a simple program to display the value of TESTVAR, I get (null). I can set the environment variable using:
export TESTVAR=testvalue
but of course that doesn't stay when i login next time. Also, I'm not sure if bash variables will work, because I am using the variables in a CGI program that isn't really run from a shell.

any ideas?

PhatBarren
11-28-2001, 02:36 PM
OKAY.....
figured out how to solve all my problems: .htaccess
man, i love these files! so much you can do with them
:D