BeBot - An Anarchy Online and Age Of Conan chat automaton

Archive => Anarchy Online Archive => BeBot 0.2 support => Topic started by: tylerp on January 09, 2007, 02:23:42 am

Title: Problem with 2.10 Connecting to MySQL
Post by: tylerp on January 09, 2007, 02:23:42 am
So I set everything up, and I got confirmation messages that I did everything correctly.. I try running the bot and the window flashes for a split second, so I opened the debug to figure out the problem. This is what it says, I have no idea how to fix it. Please help, I know nothing about MySQL.


Warning: mysql_connect(): Access denied for user 'ODBC'@'localhost' (using passw
ord: NO) in C:\Documents and Settings\Tyler\Desktop\BeBot\MySQL.php on line 63
MySQL error (# 0) on query: Cannot connect to the database server!
Access denied for user 'ODBC'@'localhost' (using password: NO)
Title: Re: Problem with 2.10 Connecting to MySQL
Post by: Xenixa on January 09, 2007, 03:36:50 am
Silly question, but did you actually make a MySQL user named ODBC?

Please post the contents of your mysql.conf file. Should look something like this:

<?
    $dbase = "bebot";
    $user = "bebotuser";
    $pass = "password";
    $server = "localhost";
?>

P.S. The above is just an example. You can mask out the password so others here don't see it. And please read this very carefully -> http://bebot.link/index.php/topic,384.0.html
Title: Re: Problem with 2.10 Connecting to MySQL
Post by: tylerp on January 09, 2007, 03:47:30 am
No, I didn't make a user with that name, I think it defaulted back to that when something went awry. Um, I could try making one and setting privileges I guess..

Code: [Select]
class MySQL
{
var $CONN = "";
var $DBASE = "Items";
var $USER = "tyler";
var $PASS = "********";
var $SERVER = "localhost";

function MySQL()
{
$this -> error_count = 0;
$this -> last_error = 0;
$this -> last_reconnect = 0;

/*
Load up config
*/
include "conf/MySQL.conf";

$this->USER = tyler;
$this->PASS = ********;
$this->SERVER = localhost;
$this->DBASE = Items;

$this -> connect(true);

return true;
}

function connect($fatal = false)
{
$conn = mysql_connect($this -> localhost, $this -> root, $this -> *******, true);

if (!$conn)
{
$this->error("Cannot connect to the database server!", $fatal);
return false;
}
if(!mysql_select_db($this -> DBASE, $conn))
{
$this->error("Database not found or insufficient priviledges!", $fatal);
return false;
}
echo "Connected to MySQL\n";
$this->CONN = $conn;
$this->error_count = 0;
}


function error($text, $fatal = false)
{
// Check if more than 30 seconds has passed since the last error
if (time() >= ($this -> last_error + 30))
{
// If so reset the error count
$this -> error_count = 0;
}

// We display a maximum of 10 errors every 10 seconds to prevent flooding of the logs/console
if ($this -> error_count <= 10)
{
$msg = mysql_error();
echo "MySQL error (# " . $this -> error_count . ") on query: $text\n";
echo "$msg\n";

// If this error is occuring while we are trying to first connect to the database when starting
// rthe bot its a fatal error.
if ($fatal == true)
{
exit;
}

// Did we just loose the connection to the database server?
if (strcasecmp($msg, "MySQL server has gone away") == 0)
{
// We wait 30 seconds between each reconnect attempt
if (time () >= ($this -> last_reconnect + 30))
{
// Lets reconnect
echo "Attempting reconnect to MySQL server...\n";
$this -> last_reconnect = time();
$this -> connect(false);
}
}
$this -> error_count += 1;
$this -> last_error = time();
if ($this -> error_count == 11)
{
echo "Threshold of 10 errors in 30 seconds reached. Supressing error output for 30 seconds\n";
}
}

}


function select ($sql)
{
$data = "";
$result = mysql_query($sql, $this->CONN);

if (!$result)
{
$this -> error($sql);
return false;
}

if (empty($result))
{
return false;
}

$count = 0;

while ($row = mysql_fetch_array($result, MYSQL_NUM))
{
$data[$count] = $row;
$count++;
}

mysql_free_result($result);
return $data;
}


function query ($sql)
{

$return = mysql_query($sql, $this->CONN);

if (!$return)
{
$this -> error($sql);
}
}


function returnQuery ($sql)
{
return mysql_query($sql, $this->CONN);
}


function dropTable ($sql)
{
$result = mysql_query("DROP TABLE " . $sql, $this->CONN);
}
}
?>
Title: Re: Problem with 2.10 Connecting to MySQL
Post by: Xenixa on January 09, 2007, 03:58:08 am
Well there's your problem right there. You edited the MySQL.php file. DO NOT edit that file.

Please find the file ..\Root_path_to_Bebot\conf\mysql.conf and set the variables there.

From the Setup guide:
Phase 3: Logging into MySQL
1. Open a command prompt. (Start > Run > CMD, Click OK)
2. In the command prompt, enter the command mysql -u root -p
3. Enter your root password (You did write it down so you wouldn't forget it right?)

You should now have a MySQL prompt that looks like: mysql>

Phase 4: Create a Database and Database User for BeBot
1. Type CREATE DATABASE databasename; (replace databasename with the name of the database you wish to create)
2. Press Enter/Return.
3. CREATE USER username@localhost; (Change username to the username you want, keep @localhost)
4. Press Enter/Return.
5. SET PASSWORD FOR username@localhost = PASSWORD('newpassword'); (Change username and newpassword to your selected username and password, again keep @localhost)
6. Press Enter/Return.
7. Type GRANT ALL on databasename.* TO username@localhost; (Again, change username, keep @localhost)
8. Press Enter/Return.
9. Type quit then Enter/Return to exit the MySQL Monitor.
Title: Re: Problem with 2.10 Connecting to MySQL
Post by: tylerp on January 09, 2007, 04:35:46 am
Problem fixed, bot is up and running. Thanks!!
Title: Re: Problem with 2.10 Connecting to MySQL
Post by: Xenixa on January 09, 2007, 05:18:26 am
Your welcome.   8)
SimplePortal 2.3.7 © 2008-2024, SimplePortal