Automate Install/Configuration of MySQL on Linux

Automate Install/Configuration of MySQL on Linux

am 27.07.2010 22:56:30 von Todd E Thomas

I'm looking for automation direction...

I've found many packages that sit on top of MySQL. For the purposes of
consistency I'd like to automate these installs.

I've been able to automate the install and configuration of everything
except the mysql part.

I'm using CentOS 5.5. Installing/verifying is no big deal.

It's the MySQL configuration that's holding me up.

Basically I've created an expect script. It works 99% but it's a PITA to
finish. Here's what I'd like to accomplish:
*Set the default admin password
# mysqladmin -u root password 'root-password'

*login to mysql
mysql> mysql -u root -p

*Drop the anonymous accounts
mysql> DELETE FROM mysql.user WHERE user = '';

*Sync all of the root passwords
mysql> UPDATE mysql.user SET Password = PASSWORD('root-password')
WHERE User = 'root';

*Remove the test database:
mysql> drop database test;


In another script I would like to create databases for specific
packages. EG:
Concrete5, for example needs:
GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, ALTER ON
concrete5.db TO 'admin'@'localhost' IDENTIFIED BY 'admin-password';



If there is a better way to do this than using expect I would greatly
appreciate any pointers in the right direction. Bash is comfortable for
me and perl is within reach. I'm not much versed in anything else right now.


--
Thanks for the assist,

Todd E Thomas
"It's a frail music knits the world together."
-Robert Dana

--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe: http://lists.mysql.com/mysql?unsub=gcdmg-mysql-2@m.gmane.org

Re: Automate Install/Configuration of MySQL on Linux

am 28.07.2010 08:49:06 von Rob Wultsch

On Tue, Jul 27, 2010 at 1:56 PM, Todd E Thomas wr=
ote:
> I'm looking for automation direction...
>
> I've found many packages that sit on top of MySQL. For the purposes of
> consistency I'd like to automate these installs.
>
> I've been able to automate the install and configuration of everything
> except the mysql part.
>
> I'm using CentOS 5.5. Installing/verifying is no big deal.
>
> It's the MySQL configuration that's holding me up.
>
> Basically I've created an expect script. It works 99% but it's a PITA to
> finish. Here's what I'd like to accomplish:
> =A0*Set the default admin password
> =A0 =A0# mysqladmin -u root password 'root-password'
>
> =A0*login to mysql
> =A0 =A0mysql> mysql -u root -p
>
> =A0*Drop the anonymous accounts
> =A0 =A0mysql> DELETE FROM mysql.user WHERE user =3D '';
>
> =A0*Sync all of the root passwords
> =A0 =A0mysql> UPDATE mysql.user SET Password =3D PASSWORD('root-password'=
) WHERE
> User =3D 'root';
>
> =A0*Remove the test database:
> =A0 =A0mysql> =A0drop database test;
>
>
> In another script I would like to create databases for specific packages.
> EG:
> Concrete5, for example needs:
> GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, ALTER ON concrete5.db=
TO
> 'admin'@'localhost' IDENTIFIED BY 'admin-password';
>
>
>
> If there is a better way to do this than using expect I would greatly
> appreciate any pointers in the right direction. Bash is comfortable for m=
e
> and perl is within reach. I'm not much versed in anything else right now.
>


If you are serious about spending time and doing automation well then
Puppet or cfengine would be the way to go.

As for the basic tasks that you describe, have you considered
modifying the rpm/deb/whatever to distribute a data dir with whatever
you want?

In addition, do you really need expect? Could you get the same effect
with good use of the sleep command inside bash?


--=20
Rob Wultsch
wultsch@gmail.com

--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe: http://lists.mysql.com/mysql?unsub=3Dgcdmg-mysql-2@m.gmane.o rg

Re: Automate Install/Configuration of MySQL on Linux

am 29.07.2010 17:45:42 von Todd E Thomas

--------------010403010102000704040309
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 8bit

To answer both emails...

My first install is Puppet :)

1) I have many clients (schools with Macs/Linux) that could use this
package. This is in the works - good call.

For the sake of DRP (Disaster Recovery Planning) I automate all of my
installs on the 1% off-chance that my backups are partially fouled for
some reason.

2) I used the .sql file that you recommended and wow - it's so much
easier than expect.

Once I had the right key-words (mysql .sql script) Google returned the
right pages:

4.5.1.4. Executing SQL Statements from a Text File
http://dev.mysql.com/doc/refman/5.0/en/batch-commands.html

The problem I have now is variable substitution. But, that's another thread.

Thanks guys,

TT





On 07/27/2010 11:40 PM, Andrés Tello wrote:
> just place all your sql sentences in a file, setup the database and
> then use:
>
> mysql -uroot -hlocalhost < file_with_allsql_you_need.sql
> or
> cat file_file_with_allsql_you_need.sql | mysql -u root -hlocalhost
>
> and you are done.
>
>
> On Tue, Jul 27, 2010 at 3:56 PM, Todd E Thomas
> > wrote:
>
> I'm looking for automation direction...
>
> I've found many packages that sit on top of MySQL. For the
> purposes of consistency I'd like to automate these installs.
>
> I've been able to automate the install and configuration of
> everything except the mysql part.
>
> I'm using CentOS 5.5. Installing/verifying is no big deal.
>
> It's the MySQL configuration that's holding me up.
>
> Basically I've created an expect script. It works 99% but it's a
> PITA to finish. Here's what I'd like to accomplish:
> *Set the default admin password
> # mysqladmin -u root password 'root-password'
>
> *login to mysql
> mysql> mysql -u root -p
>
> *Drop the anonymous accounts
> mysql> DELETE FROM mysql.user WHERE user = '';
>
> *Sync all of the root passwords
> mysql> UPDATE mysql.user SET Password =
> PASSWORD('root-password') WHERE User = 'root';
>
> *Remove the test database:
> mysql> drop database test;
>
>
> In another script I would like to create databases for specific
> packages. EG:
> Concrete5, for example needs:
> GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, ALTER ON
> concrete5.db TO 'admin'@'localhost' IDENTIFIED BY 'admin-password';
>
>
>
> If there is a better way to do this than using expect I would
> greatly appreciate any pointers in the right direction. Bash is
> comfortable for me and perl is within reach. I'm not much versed
> in anything else right now.
>
>
> --
> Thanks for the assist,
>
> Todd E Thomas
> "It's a frail music knits the world together."
> -Robert Dana
>
> --
> MySQL General Mailing List
> For list archives: http://lists.mysql.com/mysql
> To unsubscribe:
> http://lists.mysql.com/mysql?unsub=mr.criptos@gmail.com
>
>

--------------010403010102000704040309--