+ Post New Thread
Results 1 to 10 of 10
Coding Thread, Perl Help in Coding and Web Development; I think a perl script is in order here. We have a number of databases with a default Admin user ...
  1. #1

    Join Date
    Apr 2006
    Location
    UK
    Posts
    939
    Thank Post
    39
    Thanked 70 Times in 54 Posts
    Rep Power
    29

    Perl Help

    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.!!

  2. #2


    tom_newton's Avatar
    Join Date
    Sep 2006
    Location
    Leeds
    Posts
    4,448
    Thank Post
    865
    Thanked 839 Times in 662 Posts
    Rep Power
    194

    Re: Perl Help

    OK, first what sort of databases
    Second, how are the passwords stored? Md5? SHA?

    What OS?

  3. #3

    Join Date
    Apr 2006
    Location
    UK
    Posts
    939
    Thank Post
    39
    Thanked 70 Times in 54 Posts
    Rep Power
    29

    Re: Perl Help

    its MySql in a Linux box, passwords are just stored as text, in a varchar field.

  4. #4


    tom_newton's Avatar
    Join Date
    Sep 2006
    Location
    Leeds
    Posts
    4,448
    Thank Post
    865
    Thanked 839 Times in 662 Posts
    Rep Power
    194

    Re: Perl Help

    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

  5. #5

    Join Date
    Apr 2006
    Location
    UK
    Posts
    939
    Thank Post
    39
    Thanked 70 Times in 54 Posts
    Rep Power
    29

    Re: Perl Help

    #!/usr/bin/perl -w
    use DBI;
    $dbh = DBI->connect('dbi:mysqlerltest','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?

  6. #6

    Geoff's Avatar
    Join Date
    Jun 2005
    Location
    Fylde, Lancs, UK.
    Posts
    11,800
    Thank Post
    110
    Thanked 582 Times in 503 Posts
    Blog Entries
    1
    Rep Power
    223

    Re: Perl Help

    Not quite.

    Code:
    my $dbh = DBI->connect("DBI:mysql:database=test;host=localhost",
                             "joe", "joe's password",
                             {'RaiseError' => 1});
    Is slightly neater, and answers your question.

  7. #7

    Join Date
    Apr 2006
    Location
    UK
    Posts
    939
    Thank Post
    39
    Thanked 70 Times in 54 Posts
    Rep Power
    29

    Re: Perl Help

    is there anyway i can get it to automatically connect to all the databases, which are all on the same server?

  8. #8

    Geoff's Avatar
    Join Date
    Jun 2005
    Location
    Fylde, Lancs, UK.
    Posts
    11,800
    Thank Post
    110
    Thanked 582 Times in 503 Posts
    Blog Entries
    1
    Rep Power
    223

    Re: Perl Help

    No. You'll have to do each one in turn. eg, in a loop.

  9. #9

    webman's Avatar
    Join Date
    Nov 2005
    Location
    North East England
    Posts
    8,374
    Thank Post
    625
    Thanked 951 Times in 653 Posts
    Blog Entries
    2
    Rep Power
    318

  10. #10

    Join Date
    Apr 2006
    Location
    UK
    Posts
    939
    Thank Post
    39
    Thanked 70 Times in 54 Posts
    Rep Power
    29

    Re: Perl Help

    cheers guys, u've probably see im not a pro0grammer

SHARE:
+ Post New Thread

Similar Threads

  1. Backup Perl Script
    By ranj in forum Scripts
    Replies: 1
    Last Post: 30th April 2006, 08:02 PM

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •