LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices

Reply
 
Search this Thread
Old 09-28-2012, 01:05 PM   #1
zak100
Member
 
Registered: Jul 2009
Posts: 139

Rep: Reputation: 2
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.
 
Old 09-28-2012, 02:57 PM   #2
fernfrancis
Member
 
Registered: Feb 2009
Location: Goa(India)-Sharjah(UAE)
Distribution: RHEL,centos,fedora,ubuntu
Posts: 224

Rep: Reputation: 18
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?
 
Old 09-29-2012, 02:11 AM   #3
zak100
Member
 
Registered: Jul 2009
Posts: 139

Original Poster
Rep: Reputation: 2
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.

Last edited by zak100; 09-29-2012 at 02:13 AM.
 
Old 09-29-2012, 12:39 PM   #4
Wim Sturkenboom
Senior Member
 
Registered: Jan 2005
Location: Roodepoort, South Africa
Distribution: Slackware 10.1/10.2/12, Ubuntu 12.04, Crunchbang Statler
Posts: 3,786

Rep: Reputation: 282Reputation: 282Reputation: 282
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
 
Old 09-29-2012, 01:11 PM   #5
zak100
Member
 
Registered: Jul 2009
Posts: 139

Original Poster
Rep: Reputation: 2
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.
 
Old 10-01-2012, 02:31 AM   #6
Wim Sturkenboom
Senior Member
 
Registered: Jan 2005
Location: Roodepoort, South Africa
Distribution: Slackware 10.1/10.2/12, Ubuntu 12.04, Crunchbang Statler
Posts: 3,786

Rep: Reputation: 282Reputation: 282Reputation: 282
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.
 
Old 10-01-2012, 04:39 AM   #7
_dkode_
LQ Newbie
 
Registered: Sep 2012
Location: kerala
Distribution: debian
Posts: 11

Rep: Reputation: 0
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
 
Old 10-01-2012, 12:51 PM   #8
zak100
Member
 
Registered: Jul 2009
Posts: 139

Original Poster
Rep: Reputation: 2
Thanks _dkode_ and Wim Sturkenboom. I would try on your advice.

Zulfi.
 
Old 10-02-2012, 05:27 AM   #9
zak100
Member
 
Registered: Jul 2009
Posts: 139

Original Poster
Rep: Reputation: 2
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.

Last edited by zak100; 10-02-2012 at 05:30 AM. Reason: typing error
 
Old 10-02-2012, 07:52 AM   #10
_dkode_
LQ Newbie
 
Registered: Sep 2012
Location: kerala
Distribution: debian
Posts: 11

Rep: Reputation: 0
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
 
Old 10-03-2012, 05:37 AM   #11
zak100
Member
 
Registered: Jul 2009
Posts: 139

Original Poster
Rep: Reputation: 2
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.
 
Old 10-03-2012, 07:51 AM   #12
Shammyhealz
LQ Newbie
 
Registered: Oct 2012
Posts: 6

Rep: Reputation: Disabled
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.
 
Old 10-03-2012, 11:42 AM   #13
Wim Sturkenboom
Senior Member
 
Registered: Jan 2005
Location: Roodepoort, South Africa
Distribution: Slackware 10.1/10.2/12, Ubuntu 12.04, Crunchbang Statler
Posts: 3,786

Rep: Reputation: 282Reputation: 282Reputation: 282
@Shammyhealz: Look at the location the the gz-file; it's just the man page for mysqld
 
Old 10-04-2012, 03:52 AM   #14
_dkode_
LQ Newbie
 
Registered: Sep 2012
Location: kerala
Distribution: debian
Posts: 11

Rep: Reputation: 0
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

Last edited by _dkode_; 10-04-2012 at 09:22 AM. Reason: deta
 
Old 10-04-2012, 04:24 AM   #15
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Servers: Debian Squeeze and Wheezy. Desktop: Slackware64 14.0. Netbook: Slackware 13.37
Posts: 8,533
Blog Entries: 28

Rep: Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176
Quote:
Originally Posted by Wim Sturkenboom View Post
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.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Trying to write script that tests mysql login drigby Programming 3 04-09-2012 10:43 AM
starting mysql server using perl script vinaytp Linux - Newbie 1 05-20-2009 05:32 AM
Problem Starting MySQL on Fresh Fedora 8 Install w/ Yum'd MySQL blong4life Linux - Server 2 07-04-2008 07:44 PM
PHP login script using mysql issue ACDII Linux - Server 4 01-20-2007 04:58 AM
A good secure login script with PHP and mySQL genderbender Programming 3 05-02-2006 10:06 AM


All times are GMT -5. The time now is 11:49 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration