Gossamer Forum
Home : Products : Others : MySQLMan :

The first mod to the script?

Quote Reply
The first mod to the script?
I haven't quite figured out all the commands to MySQLMan yet, so I'm not comfortable with tinkering. I was wondering if any of you folks had any ideas for this.

When I run the script, I get a list of all the databases on the server, only one of which is mine. I click on mine and I get a login page. I enter the login info and then I go back to the list of databases and click on my database again.

How would I go about setting up the script so that I would automatically be logged on when I run it and I would have immediate access to my own database, rather than the list of other people's databases?


JPD
Quote Reply
Re: The first mod to the script? In reply to
This can be done by creating a link like:

http://the/url/to/mysql.cgi?db_host=localhost&db_user=root&db_pass=root&do=tables&data_source=DBI:mysql:test&init_login=1

where
db_host : the database host
db_user : the user name
db_pass : the password
data_source : DBI:mysql:database_name

(leave do=tables and init_login=1)

That should take you to the tables in your database directly.

Cheers,

--
Gossamer Threads, Inc.
Quote Reply
Re: The first mod to the script? In reply to
Thanks, Steve. What you gave me won't work with my server's setup, though.

I don't enter a hostname at all, or a password. Just my username. When I tried

http://the/url/to/mysql.cgi?db_user=root&do=tables&data_source=DBI:mysql:test&init_login=1

the word - PATH was entered in the hostname field and, no matter how many times I deleted it, it came back again and again.

I tried setting the demo values in the .cfg file to what I needed to log in, but that didn't do it either.

I guess it's no big deal. When I get some time, I'll see if I can go through the code to figure it out for myself.

Thanks anyway. Smile


JPD
Quote Reply
Re: The first mod to the script? In reply to
There is one other thing you can do to make it skip the login page and take you to the table list of your database.

In sub connect_db in mysql.cgi find the part where it says

if($config{'demo_mode'}){
...
$dbh = DBI->connect("$data_source", "$username", "$password", { RaiseError => 0, PrintError => 0, AutoCommit => 1 });
...
else{
...
$dbh = DBI->connect("$data_source", "$username", "$password", { RaiseError => 0, PrintError => 0, AutoCommit => 1 });
...
}

There are 2
$dbh = DBI->connect("$data_source", "$username", "$password", { RaiseError => 0, PrintError => 0, AutoCommit => 1 });
statements in the sub-routine. The first one in the IF clause is for demo only when the demo_mode is on. In the ELSE clause you can hardcode in the login info so that the script will only try to connect with the login info specified.

Replace:
"$data_source" with "DBI:mysql:database_name" OR "DBI:mysql:database_name:host_name";

""$username" with your user name; and

"$password" with your actual password.

--
Gossamer Threads, Inc.
Quote Reply
Re: The first mod to the script? In reply to
Thank you, Steven. That gets me half way there. Smile At least I've cut out two steps before I got to my database.


JPD
Quote Reply
Re: The first mod to the script? In reply to
Actually, if you use the URL
http://the/url/to/mysql.cgi?do=tables&data_source=DBI:mysql:database_name
together with the modification then you should be brought to the list of tables directly.

--
Gossamer Threads, Inc.
Quote Reply
Re: The first mod to the script? In reply to
Yes! That did it!!! Thank you, Steven!!!!!!


JPD
Quote Reply
Re: The first mod to the script? In reply to
Okay, I understand all of this but have another question.

I have mySQL setup on a dedicated server but have two instances running for two different users located on virtual servers of the dedicated server. The datadir for each user's tables is off thier home directory, for example:
Code:
/home/user/var
the .my.cnf file is located in their /home/user directory and it contains different port numbers for each user and, of course, a different socket location for each user. For example, .my.cnf for user1 might look like this:
Code:
[mysqld]
bind-address=216.163.76.113
port=3306
datadir=/home/user1/var/
socket=/tmp/mysql.user1
pid-file=/home/user1/var/mysql.pid
and for user2 it would be:
Code:
[mysqld]
bind-address=216.163.76.113
port=3307
datadir=/home/user2/var/
socket=/tmp/mysql.user2
pid-file=/home/user2/var/mysql.pid
How can I setup the script to use the correct datadir. Right now, it wants to default to user1's datadir, never seeing user2's datadir at all.

I hope this is clear.

- Bobsie
bobsie@orphanage.com
http://goodstuff.orphanage.com/
Quote Reply
Re: The first mod to the script? In reply to
Please see my other message also.

I added this to the sub connect_db:
Code:
$ENV{MYSQL_UNIX_PORT} = '/tmp/mysql.user2';
I have also applied the changes outlined in this thread and am using the URL specified, but when I try to connect, I get this:
Code:
Connection to MySQL failed. The hostname may be
different or the server may be down. Please enter a
new hostname and try again.
No matter what I do, I cannot get a connection. I even tried changing the /tmp/mysql.user2 above to 3307, the actual port number for this user's mySQL.

Any help would be appreciated.

- Bobsie
bobsie@orphanage.com
http://goodstuff.orphanage.com/