danIT Posted August 1, 2007 Posted August 1, 2007 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.!!
tom_newton Posted August 1, 2007 Posted August 1, 2007 OK, first what sort of databases Second, how are the passwords stored? Md5? SHA? What OS?
danIT Posted August 1, 2007 Author Posted August 1, 2007 its MySql in a Linux box, passwords are just stored as text, in a varchar field.
tom_newton Posted August 1, 2007 Posted August 1, 2007 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
danIT Posted August 1, 2007 Author Posted August 1, 2007 #!/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?
Geoff Posted August 1, 2007 Posted August 1, 2007 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.
danIT Posted August 1, 2007 Author Posted August 1, 2007 is there anyway i can get it to automatically connect to all the databases, which are all on the same server?
Geoff Posted August 1, 2007 Posted August 1, 2007 No. You'll have to do each one in turn. eg, in a loop.
webman Posted August 1, 2007 Posted August 1, 2007 Arrays and loops? http://www.cs.cf.ac.uk/Dave/PERL/node1.html http://cgi101.com/
danIT Posted August 1, 2007 Author Posted August 1, 2007 cheers guys, u've probably see im not a pro0grammer
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now