473,406 Members | 2,816 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

statments issued ad server startup

Hi,

I would like to issue three statements to the database (mysql v4.1)
each time the server starts up. Is there any built in way to do this?
Like a init file to put them in?

At the moment I have a perlscript that starts the server and issues
these statements but I have to supply password each time. It feels
like there could be a better way of solving this..

//Jesper
Jul 23 '05 #1
4 1426
Jesper wrote:
I would like to issue three statements to the database (mysql v4.1)
each time the server starts up. Is there any built in way to do this?
Like a init file to put them in?


You don't mention what operating system you're on. On UNIX/Linux, the
way to do this would be to start mysql in an init script (probably in
/etc/init.d or /etc/rc.d/init.d depending on your platform).

I would recommend scripting your other startup tasks in a separate
script, but link it in the rc.d directories as a `SnnMyScript' script,
where nn is a number greater than the number of your mysql startup
script link. For example, if mysql is S71mysqld, make your own script
at least S72MyScript.

Refer to docs on init if you don't understand what I'm talking about.

Regards,
Bill K.
Jul 23 '05 #2
I think my question was a little unclear. Sorry ... It is not the
problem of running a scipt or starting a service when the computer
starts up. But the problem of issuing statements to the MySQL
-database everytime it is started.
These are the statements:

select initprobedata(id,filename) from AFFYMETRIX.PROBEDATAFILES;
select initqnormdata(id,filename) from AFFYMETRIX.QNORM;

Right now I have a "wrapper" script written in perl that starts mysql
(with /etc/init.d/mysql start) connects to the database and issues my
statments. The problem here is that I don't want passwords to the
database my script and therefore have to supply it every time... Can I
somehow avoid this by putting the statements in a initiation file that
are automatically issued to the mysql database at startup?

(I am running a mysql 4.1 on Fedora 2 system)

//Jesper
Bill Karwin <bi**@karwin.com> wrote in message news:<d1*********@enews2.newsguy.com>...
Jesper wrote:
I would like to issue three statements to the database (mysql v4.1)
each time the server starts up. Is there any built in way to do this?
Like a init file to put them in?


You don't mention what operating system you're on. On UNIX/Linux, the
way to do this would be to start mysql in an init script (probably in
/etc/init.d or /etc/rc.d/init.d depending on your platform).

I would recommend scripting your other startup tasks in a separate
script, but link it in the rc.d directories as a `SnnMyScript' script,
where nn is a number greater than the number of your mysql startup
script link. For example, if mysql is S71mysqld, make your own script
at least S72MyScript.

Refer to docs on init if you don't understand what I'm talking about.

Regards,
Bill K.

Jul 23 '05 #3
Jesper wrote:
I think my question was a little unclear. Sorry ... It is not the
problem of running a scipt or starting a service when the computer
starts up.
Well, I was suggesting that you could write an init script which doesn't
start any service, it just executes SQL statements. There's no rule
that init scripts must be used only to start services.

But I'm not sure if you mean that you want your SQL statements to run
each time the computer starts, or on some other schedule. If the
latter, you should use cron.
But the problem of issuing statements to the MySQL
-database everytime it is started.
These are the statements:

select initprobedata(id,filename) from AFFYMETRIX.PROBEDATAFILES;
select initqnormdata(id,filename) from AFFYMETRIX.QNORM;

Right now I have a "wrapper" script written in perl that starts mysql
(with /etc/init.d/mysql start) connects to the database and issues my
statments.
I'm a little confused... from your description, it sounds like you think
/etc/init.d/mysql needs to be run when you want to connect to a
database. That's not usually the case. /etc/init.d/mysql is typically
run at boot-time, and it starts a mysqld process which persists while
the machine is running. Then anytime you want to access a database, you
can use the client tools like mysql or mysqldump, or you can write your
own script using Perl/DBI or the like. But mysqld continues to run in
the meantime.

Anyway, that's the traditional way to use it. Of course, it's possible
to set things up so that mysqld _isn't_ started at boot-time, and then
you'd have to run /etc/init.d/mysql start (or mysqld_safe, which is run
by that script) the first time you want to use a database. But then you
wouldn't have to start up mysqld again unless you deliberately shut it down.

If you have an environment in which you have the mysqld server process
coming up and down irregularly, you could consider editing the
mysqld_safe script. Add a call to your Perl script (minus its
invocation of /etc/init.d/mysql, or else you'll have an infinite loop),
somewhere in mysqld_safe after that script has succeeded in starting the
mysqld process. I have never tried this, however, so I can't vouch for
this method.
The problem here is that I don't want passwords to the
database [in] my script and therefore have to supply it every time... Can I
somehow avoid this by putting the statements in a initiation file that
are automatically issued to the mysql database at startup?


There's a .my.cnf file, and there's a MYSQL_PWD environment variable,
which can each be used to store a password so you don't have to type it.
I recommend using the .my.cnf file, but make sure you chmod it to
prevent unauthorized people from reading it.

Read these pages:
http://dev.mysql.com/doc/mysql/en/pa...-security.html
http://dev.mysql.com/doc/mysql/en/option-files.html

Regards,
Bill K.
Jul 23 '05 #4
je****@sbc.su.se (Jesper) wrote in
news:3c**************************@posting.google.c om:
I think my question was a little unclear. Sorry ... It is not the
problem of running a scipt or starting a service when the computer
starts up. But the problem of issuing statements to the MySQL
-database everytime it is started.
These are the statements:

select initprobedata(id,filename) from AFFYMETRIX.PROBEDATAFILES;
select initqnormdata(id,filename) from AFFYMETRIX.QNORM;

Right now I have a "wrapper" script written in perl that starts mysql
(with /etc/init.d/mysql start) connects to the database and issues my
statments. The problem here is that I don't want passwords to the
database my script and therefore have to supply it every time... Can I
somehow avoid this by putting the statements in a initiation file that
are automatically issued to the mysql database at startup?

(I am running a mysql 4.1 on Fedora 2 system)


One solution is to create a mysql user with restricted SELECT privileges
that doesn't require a password from localhost. This is an acceptable
approach if the data isn't sensitive in your local environment;

GRANT SELECT ON AFFYMETRIX.PROBEDATAFILES TO 'foo'@'localhost';
GRANT SELECT ON AFFYMETRIX.QNORM TO 'foo'@'localhost';
FLUSH PRIVILEGES;

That limits the user to the specified tables, but you restrict the
columns, too:

GRANT SELECT (col1, col2) ON AFFYMETRIX.QNORM TO 'foo'@'localhost';

Jul 23 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: T Stoneman | last post by:
I was wondering if PHP has some type of initialization functionality at startup where I can run a script when the web server first boots up? I have an Apache server running PHP, and I would like...
3
by: jabailo | last post by:
I've built a remoting solution with a client and a server. I want to start the server, and then run the client against it. Since I can only make one project in a solution be the "Set As Startup...
3
by: Vinny Vinn | last post by:
I have used simple batch statments with C#.for example: string select = "select model from cars where id = ?;select * from trucks where model = ?"; where ? is a parameter whose value i have...
17
by: Danieltbt05 | last post by:
just installed SQL server 2000 and using my client , i can't locate the server. I used SQL query analyzer to search but no servers were found. Error message is as below Server : Msg17,level...
3
by: steveeisen | last post by:
I'm a long-time VB6 programmer in a shop that is mostly moving to VB ..NET 2005. And I'm confused about coding the start of solutions for unattended operations. Much of what I write is old-time...
2
by: Pete Vickers [MVP] | last post by:
Hi, I have a project, that doesn't appear to process frmMain at all - I break at form_load, and nothing happens. The form shows, but has done no processing in the form load. I have tried having...
1
by: Syl | last post by:
Hello! Can someone verify this for me please. Should these 2 statments return the same result ? The 2nd one is the original, the first one is my re-write. Thanks : SELECT orders_status,...
0
by: kyon | last post by:
Hi all, I have a problem: I had installed a oracle 8i to a microsoft server 2003. However, the database is not startup automatically if the machine is re-booted. I know the database can...
3
by: matias.cornejo | last post by:
I have a problem to startup de DB2 Admin. I read meny documentation in internet and nothing work, anybody know something??. I have DB2 UDB V8 fixpack 14 and AIX 5.2 x134 db2admin start SQL4409W...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.