LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (http://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Starting mysql using login script (http://www.linuxquestions.org/questions/linux-newbie-8/starting-mysql-using-login-script-4175429476/)

zak100 09-28-2012 02:05 PM

Starting mysql using login script
 
Hi,
Can sombody plz guide me how to start mysql using a login script. I dont want to type pasword.

Zulfi.

fernfrancis 09-28-2012 03:57 PM

can you please elaborate

what operating system your using , the version of mysql etc ...

what do u mean by login script ? what are you trying to achieve?

zak100 09-29-2012 03:11 AM

Hi,
Thanks for your response. I am using Fedora 1o. I want to start sqld and some people on this forum helped me for this. However I have to use :
Code:

su
mysqld

commands which asks password. That's why I want to create a login script so that no body can see the passwd. Kindly guide me:

i)how to write the script for executing the above commands without providing the passwd. The script should be able to execute at the time of guest user's login.
ii) in which file i have to store the script.

Zulfi.

Wim Sturkenboom 09-29-2012 01:39 PM

Is there a specific reason why you don't want the mysql daemon to be started at startup?

Quote:

commands which asks password. That's why I want to create a login script so that no body can see the passwd.
Nobody can see the password when you type it ;)

Quote:

how to write the script for executing the above commands without providing the passwd
Not possible (to my knowledge) when using 'su'. I guess Fedora has support for 'sudo', so you should be able to set that up so (one or more) users can start the mysql daemon without need for a password.

A last note: your title states mysql (the mysql client), your thread is about mysqld (the mysql daemon). There is a difference between the two ;)

zak100 09-29-2012 02:11 PM

Thanks for the correction of the title.

Quote:

Is there a specific reason why you don't want the mysql daemon to be started at startup?

No. This is what i want. mysqld is not starting at boot time. I have to first login to guest account and then i have to run mysqld. Its a teaching environment. I want to start it after the OS (Fedora) is loaded or after the guest login. Otherwise i have to run mysqld on all PCs and this would allow leakage of passwd.

I want to start mysqld at startup or at guest login and this is what i am looking for.

I dont know about sudo but how can i use it in a login script?

Zulfi.

Wim Sturkenboom 10-01-2012 03:31 AM

Quote:

I want to start mysqld at startup or at guest login
If it does not matter, let it start when the system boots (you don't need to know the password for that). If that does not work, check why it does not work and fix that. I'm not a fedora man so I can't say what to do to get it automatically started in fedora.

Quote:

I dont know about sudo but how can i use it in a login script?
Code:

sudo mysqld
But you have to setup 'sudo', something I have not played with.

Maybe more knowledgeable people can give the finer details.

_dkode_ 10-01-2012 05:39 AM

see http://www.mjmwired.net/resources/mj...es.html#enable
It explain how to set up services in fedora.

There is some graphical utilities where you can enable or disable services by clicking the checkboxes.

or you can allow some users with permission to run specified commands as root by sudo, all you need is to edit /etc/sudoers file using visudo.
eg:-
[user] ALL=(ALL) NOPASSWD: [command]
replace [user] and [command] with appropriate values.
then you can execute:
sudo [command] without any password if logged in as [user].

Also check.
man sudo
man sudoers

zak100 10-01-2012 01:51 PM

Thanks _dkode_ and Wim Sturkenboom. I would try on your advice.

Zulfi.

zak100 10-02-2012 06:27 AM

Hi,
I tried to change the following line in sudoers file:

Code:

# %wheel ALL=(ALL) NOPASSWD:ALL
with
Code:


guest ALL=(ALL) NOPASSWD:sqld

but its giving me error when i tried to save the file. It says:
Code:

>>> sudoers file: syntax error, line 84 <<<
what now?

Kindly guide me.

Zulfi.

_dkode_ 10-02-2012 08:52 AM

use the full path(absolute path) for the command.
if you don't know the path, use 'whereis' to find it.

Assuming you need to run sqld as root.

#whereis sqld
this will give you the path, lets say /usr/sbin/sqld
then you can change your sudoers entry to:
Quote:

guest ALL=(ALL) NOPASSWD: /usr/sbin/sqld
you may need to use mysqld instead of sqld

zak100 10-03-2012 06:37 AM

Hi,

Thanks for your response.

I tried :
Code:

## Same thing without a password
guest ALL=(ALL) NOPASSWD: /usr/libexec/mysqld

but I am getting following error:
Code:

[guest@HP-UX646UU ~]$ sudo service mysqld start
[sudo] password for guest:
Sorry, user guest is not allowed to execute '/sbin/service mysqld start' as root on HP-UX646UU.
[guest@HP-UX646UU ~]$

The root path for mysqld is:

Code:


[guest@HP-UX646UU ~]$ su
Password:
[root@HP-UX646UU guest]# whereis mysqld
mysqld: /usr/libexec/mysqld /usr/share/man/man8/mysqld.8.gz

Kindly guide me with this problem.

Zulfi.

Shammyhealz 10-03-2012 08:51 AM

I'm a bit of a noob, so I may be wrong, but I didn't think gz was a type of executable file? Google seems to confirm this.

Also, it would appear that you may have changed your sudoers file to make the sudo command log in as guest, not as root.

Wim Sturkenboom 10-03-2012 12:42 PM

@Shammyhealz: Look at the location the the gz-file; it's just the man page for mysqld

_dkode_ 10-04-2012 04:52 AM

You are using: sudo service mysqld start
you need to add the command /sbin/service mysql start, in sudoers.
not mysqld

*edited

Quote:

Code:

## Same thing without a password
guest ALL=(ALL) NOPASSWD: /usr/libexec/mysqld

but I am getting following error:
Code:

Code:

[guest@HP-UX646UU ~]$ sudo service mysqld start
[sudo] password for guest:
Sorry, user guest is not allowed to execute '/sbin/service mysqld start' as root on HP-UX646UU.
[guest@HP-UX646UU ~]$


in this settup you can run, without password
Code:

sudo mysqld
to execute
Code:

sudo service mysqld start
without password, you need to add entry
Code:

guest ALL=(ALL) NOPASSWD: /sbin/service mysqld start
there is also a short cut to allow executing all command as root without password in sudo, I use that in my servers. but it is dangerous if the guest account is accessible to persons other than administrators. if you use it, use with care or do not use.
Code:

guest ALL=(ALL) NOPASSWD: ALL

catkin 10-04-2012 05:24 AM

Quote:

Originally Posted by Wim Sturkenboom (Post 4793723)
If it does not matter, let it start when the system boots (you don't need to know the password for that). If that does not work, check why it does not work and fix that.

+1 to that. It is the normal way to start mysqld and is routinely used on many many systems.


All times are GMT -5. The time now is 04:13 AM.