PDA

View Full Version : Connecting to the MySQL database



jorgen99
2007-03-05, 11:56
Is it possible to connect to the slimserver mysql database using
the MySql Query Browser or Administrator.
When I try to connect I just get an error message saying I can't
connect.

I know that the MySql that slimserver uses is a trimmed down
version and I thought maybe I could alter some config file to
get it to work. Or should I set up a "real" MySql instance and
follow the documentation on the wiki on how to use an already
existing database?

mherger
2007-03-06, 02:30
> I know that the MySql that slimserver uses is a trimmed down
> version and I thought maybe I could alter some config file to
> get it to work.

my.tt

--

Michael

-----------------------------------------------------------------
http://www.herger.net/SlimCD - your SlimServer on a CD
http://www.herger.net/slim - AlbumReview, Biography, MusicInfoSCR

JJZolx
2007-03-06, 09:12
Is it possible to connect to the slimserver mysql database using
the MySql Query Browser or Administrator.
When I try to connect I just get an error message saying I can't
connect.

I know that the MySql that slimserver uses is a trimmed down
version and I thought maybe I could alter some config file to
get it to work. Or should I set up a "real" MySql instance and
follow the documentation on the wiki on how to use an already
existing database?

By default the SlimServer MySQL instance only binds to the localhost IP address (127.0.0.1) and listens on port 9902. You can easily connect to it using tools such MySQL Query Browser or Administrator, but only if running the tools on the same machine. If you want to connect to the database from a different machine then you'll need to have MySQL listen on an IP address accessible across the network. In /server/MySQL/my.tt you would edit the 'bind-address' line. If you remove it (or comment it out) then MySQL will listen on all IP addresses that are bound to the machine.

jorgen99
2007-03-06, 14:20
Thanks it's working now.

This is a quite verbose write down of how I did it. Perhaps it
will help someone else with the same problem.

First i edited the my.tt file. I commented the skip-grant-tables
line and set the bind-address to the real ip (192.168.0.4 instead
of 127.0.0.1).

Then i restarted the slimserver to make the changes take effect.
I run the server on my Ubuntu box and this is the command for that.

propmpt>sudo /etc/init.d/slimserver restart

(Note to non-linux (debian) types. sudo makes you run the command
as the super user)

But when I tried to connect I still got an error message from
MySql Administrator saying something about me not having
permission to connect.

After a bit of Googeling I found this page:
5.9.2. Adding New User Accounts to MySQL
http://dev.mysql.com/doc/refman/5.0/en/adding-users.html

So I have to grant a user access to the tables by using
this command:
mysql> GRANT ALL PRIVILEGES ON *.* TO 'some_user'@'%'
-> IDENTIFIED BY 'some_pass' WITH GRANT OPTION;

Note that there is a ' surrounding both the user name and the %.
When I first tried it I read it like 'some_user@%' instead of
'some_user'@'%'.

This will make it possible for some_user to access mysql from
any host. This can be a temporary user since once I get
MySQL Administrator up and running I can manage all user from
there.

More problems...
When i tried the mysql command I got this error message:
Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock'

More Googeling and I found this page:
http://www.tech-recipes.com/mysql_tips762.html

The solution is to look in the my.tt file and find the "socket"
parameter, in my case /var/cache/slimserver/slimserver-mysql.sock

So I tried again, this time also specifying user and port:
prompt>mysql --user=root --port=9092 --socket=/var/cache/slimserver/slimserver-mysql.sock

Then connect...
mysql>connect

Switch to the 'mysql' database:
mysql>use mysql;

Now I ran the GRANT-stuff mentioned above and after that:
mysql>select * from user;

to verify that there was a line with my containing my 'some_user'.

And then I could connect with the MySql Query Browser and MySql
Administrator.

/Jörgen

jorgen99
2007-03-06, 16:45
I forgot...

I also changed the property 'dbsource' in the /etc/slimserver/slimserver.pref file.

Changed value 127.0.0.1 to 192.168.0.4 like this:
dbsource: dbi:mysql:hostname=192.168.0.4;port=9092;database= %s

I don't know if this was necessary but it seems to be working... :)

/Jörgen

JJZolx
2007-03-06, 17:02
I forgot...

I also changed the property 'dbsource' in the /etc/slimserver/slimserver.pref file.

Changed value 127.0.0.1 to 192.168.0.4 like this:
dbsource: dbi:mysql:hostname=192.168.0.4;port=9092;database= %s

I don't know if this was necessary but it seems to be working... :)

I wondered about that. Yes, it's necessary. The trouble with MySQL is that it either listens on all IP addresses or exactly one. I think you could have saved yourself all of this work by simply letting MySQL listen on all addresses by removing the bind-address directive.

When you designate 192.168.0.4 as the bind address, it no longer listens on the 127.0.0.1 localhost address, so you had to go through all the user permission stuff as well as reconfigure SlimServer to use that address.