SQL database connection

I apologize if I'm posting in the wrong place. I have been trying for several days to figure this out but unable to. I keep getting
Code:
Unable to connect to SQL database
but I can't figure out how to fix the problem. I attached the file with the piece of code that tries to connect to the SQL database (line 58). Please help me figure this out. FYI, try to use layman's terms because I'm not that experienced with FreeBSD. Thank you.
 

Attachments

  • db.c
    8.9 KB · Views: 279
The error message on line 58 is triggered once mysql_real_connect() fails to connect to your MySQL database server.

You might want to review the documentation of the MySQL C-API, the description of said function is here:
http://dev.mysql.com/doc/refman/5.6/en/mysql-real-connect.html

Conforming to the function description, you are asking for a MySQL connection to a server listening on the local domain socket for user "starmud" having a blank password for the database "starmud".

Code:
...
   if (mysql_real_connect(dbh, NULL, "starmud", NULL, "starmud", 0, NULL, 0) == NULL) {
      mysql_close(dbh);
      error("Unable to connect to SQL database.\n");
   }
...
Said call would fail, if either or all of the following is not given:
  • the server is not running or not listening on the local domain socket -- check the socket location
  • the user "starmud" or database "starmud" does not exist
  • the password for user "starmud" is set, i.e. is not blank

Try on the command line:
mysql --user=starmud --database=starmud

Show us the output of that command.
 
http://dev.mysql.com/doc/refman/5.6/en/ ... nnect.html I reviewed the documentation at the link above but it did not help me much.

I tried the following on the command line: mysql --user=starmud --database=starmud. The output of that command:
Code:
ERROR 2002 (HY00): Can't connect to local  MySQL server through socket '/tmp/mysql.sock' (2)

Then I checked the directory /tmp/ but I did not find anything called mysql.sock. All I found are the following:

Directories:
  • /root/tmp/fam-root/
  • /root/tmp/fam-starmud/
  • /root/tmp/kde-root/
  • /root/tmp/kde-starmud/
  • /root/tmp/ksocket-root/
  • /root/tmp/ksocket-starmud/
Files:
  • dbus-3TDmgi3Pv2
  • dbus-gK7t110IVD
  • dbus-vDM9FIuQx4
  • virt_1111
  • virtuoso_Ha6365.ini
  • virtuoso_MJ2403.ini
  • virtuoso_MJ7214.ini
 
Code:
7028    ??    I          0:00.05    /bin/sh /usr/local/bin/mysqld_safe --defaults -f
7143    ??    I          0:14.10    /usr/local/libexec/mysqld --defaults-file=/home
 
This is what I get when I type sockstat | grep mysql.

This was repeated 11 times:
Code:
starmud mysql 7143 10 stream /home/starmud/.local/share/akonadi/db_misc/mysql.socket

This was repeated 10 times:
Code:
starmud akonadiser 7027 10 stream -> /home/starmud/.local/share/akonadi/db_misc/mysql.socket
 
AH! Your database is listening (or wants to listen) on a different socket than the normal default. Try this:
mysql --user=starmud --database=starmud --socket=/home/starmud/.local/share/akonadi/db_misc/mysql.socket
 
I'm sorry it was a typo. Yes it does say mysqld in the second column.

This is what I get after typing that line:
Code:
ERROR 1049 (42000): Unknown database 'starmud'
 
Well, that means that a connection to the MySQL server is being made, but there is no database named "starmud" there. See if the following commands get you a list of the databases that ARE available:
Code:
mysql  --socket=/home/starmud/.local/share/akonadi/db_misc/mysql.socket
show databases;
quit
 
starmud said:
No.

This is what I get after typing that line:
Code:
ERROR 1049 (42000): Unknown database 'starmud'

Well it's time now, that you tell us more about your setup. Start by showing to us the output of the command uname -a. Then tell us who did the present (strangely screwed) MySQL installation for what purpose. Finally explain a little bit more what you want to achieve based on that screwed installation.
 
Code:
+------------------------------+
| Database                       |
+------------------------------+
| information_schema       |
| akonadi                         |
| mysql                            |
| test                               |
+------------------------------+
 
After typing uname -a:
Code:
FreeBSD pcbsd-1762 8.2-RC2 FreeBSD 8.2-RC2 #5: Tue Jan 11 12:31:01 PST 201
1      root@build8x32.pcbsd.org:/usr/obj/usr/local_storage/pcbsd-build82/fbsd-source/8.2/sys/PCBSD   i386
All I did was install the OS. Why is MySQL screwed up? I wanted to install this to run a MUD (Multi User Dungeon) which is a text-based game. They only run on Unix/Linux/FreeBSD. But I have a specific MUD that only works for FreeBSD. I ran well before in FreeBSD but the machine was fried so I installed the OS on a different machine. I guess a database called 'starmud' did exist on the old machine that fried. Perhaps it can be done again somehow?
 
So that proves that there is no database named "starmud" out there. I would have to agree with @obsigna that more information on your setup is needed; this is NOT the default way a MySQL server would be set up on FreeBSD, so who/how did it get set up? Did someone else do it and were you told specifically that a "starmud" database would be out there for you to use, or were you trying to follow some MySQL tutorial? Better help can be given with a little more information.
 
Last edited by a moderator:
I never set up MySQL. I only installed the FreeBSD OS. Perhaps setting it up would correct things?
 
You installed PC-BSD, which is based on FreeBSD but comes with some important differences, e.g. a screwed MySQL installation. See also PC-BSD DesktopBSD FreeNAS NAS4Free m0N0WALL pfSense ArchBSD.

You cannot simply reinstall MySQL, because this most probably would break akonadi, whatever the hell this is.

Anyway, FreeBSD 8.2 is end-of-life, and it is missing important security updates. Before doing anything else, you want to upgrade to at least 8.4, or even better make the jump to a new installation of 10.0, perhaps without that akonadi.

Finally, follow some tutorial about how to install a MUD.
 
When you say to install 10.0 without akonadi. The installation doesn't give the option to install without so-and-so. However it does give the option to install the shell as: /bin/sh, /bin/csh, etc.

Should I have ports installed or does that have nothing to do with MySQL?

What about the 'starmud' database, is it something I have to name myself when the time comes or is that something done during setup?

I would like to make this attempt once and to do it right.
 
Should I have ports installed or does that have nothing to do with mysql?
Yes, the standard way to install MySQL on FreeBSD is to use the ports.
What about the 'starmud' database. Is it something I have to name myself when the time comes or is that something done during setup?
Without any more information about this "specific MUD that only works for FreeBSD", I can only guess that the instructions for installing this MUD will tell you what to do, or that it will do it automatically for you.

I believe what @obsigna is suggesting is to wipe your system clean and install a newer, supported version of the FreeBSD OS, such as FreeBSD 10.0, and then follow the instructions for installing that MUD.
 
Last edited by a moderator:
Ok ports was something I chose to install during the PC-BSD installation. They did not install automatically. MUDs only have instructions on how to start the MUD driver, nothing else.

They are simply ready to connect with a database called starmud as it is written on line 56 of db.c file that I attached in my first post. I just need to know if it's possible to have a database called starmud in FreeBSD? Or if I should rename starmud to a different name that will allow for a connection to whatever database that's available.
 
starmud said:
I just need to know if it's possible to have a database called starmud in FreeBSD?

In theory, it is possible.

Install databases/mysql56-server from the ports, and initialize it and set it up for hosting the database starmud for the user starmud.

The obstacle here is, that databases are not simply empty big containers, databases are structured. And you need to provide the structure. For this reason software packets provide either a SQL database template file that the user (i.e. you) must load into mysql for setting up the database(s), or the software comes with an initialization function that is either called implicitly on the first run or explicitly before the first run by the way of a separate command.

If you neither got a SQL template file nor know of an initialization routine, and eventually don't know anybody else who got either of these facilities, then simply forget it -- trial and error will lead you straight into the middle of nowhere. I don't know anything about StarMUD -- yesterday I thought: "perhaps a dingy star" -- so, I certainly can't be of any help with that.

starmud said:
Or if I should rename starmud to a different name that will allow for a connection to whatever database that's available.

Let's assume that there is a database server in the net, e.g. with the host address starmud-db.example.com, and it provides the database starmud for the user starmud, having the password starpwd, then you would change line 56 of the file db.c to:
Code:
...
   if (mysql_real_connect(dbh, "starmud-db.example.com", "starmud", "starpwd", "starmud", 0, NULL, 0) == NULL) {
      mysql_close(dbh);
      error("Unable to connect to SQL database.\n");
   }
...

If you got only the IP address, then replace the second parameter by "ip.ip.ip.ip". If the server is not listening on the standard port 3306, then you need to pass the actual port number instead of 0 by the sixth parameter.

After the changes, you need to re-compile the DB connector.
 
Ok I made four attempts to install FreeBSD-10.0-RELEASE-i386-dvd1 and almost at the very end when I clicked configure and install I get this:
Code:
An installation step has been aborted. Would you like to restart the installation or exit the installation?
Suggestions anyone?
 
Back
Top