Jump to content

Recommended Posts

Posted

I think a perl script is in order here. We have a number of databases with a default Admin user name in, the user names all appear in the same table in each different database and there are around 100 databases i need to make the change on.

 

Could anyone point me in the direction of a useful resource or jot something down here:

 

re-write the username and password to each database: 100 databases:

the admin ID is different in each table so ill have to UPDATE by matching current Username and Password which are all identicle across the 100 databases.

 

sql: Update teachers

Set username "admin"

Set password "new"

where name = "Administrator"

 

But this needs to happen across a number of databases,

 

Any ideas welcome.!!

Posted

start by making a database connection - "man DBI" will help you with code snippets there.

 

Once you have a connection established to the server - I assume the databases are all on the same server - come back to us here and we can move on to stage 2 :)

Posted

#!/usr/bin/perl -w

use DBI;

$dbh = DBI->connect('dbi:mysql:perltest','root','password')

or die "Connection Error: $DBI::errstr\n";

 

but i need to connect to the server so i assume i can enter a ip address here instead of entering a database name : perltest?

Posted

Not quite.

 

my $dbh = DBI->connect("DBI:mysql:database=test;host=localhost",
                        "joe", "joe's password",
                        {'RaiseError' => 1});

 

Is slightly neater, and answers your question.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now



×
×
  • Create New...