Connect mysql to darkrp

Hello guys, I have some problems because of my fledgling level of english and the technicals english words used in drakehawke’s thread about mysqloo.

As you can see I am trying to connect a database to my server by following all the steps to succeed but unfortunatly I don’t manage to.

So, I downloaded these files : puu.sh/1fhWu and drakehawke-gmod.googlecode.com/svn/trunk/AndyVincentGMod/RELEASE/gmsv_mysqloo_win32.dll

  • The first file, I put it in the same folder of srcds_

  • The second file, I put it in garrysmod/lua/bin ( I had to create the folder bin).

After that, I know that I have to connect my database with my private informations but I don’t know where. As it’s said in drakehawke’s thread I have to fill in these lines :


require( "mysqloo" )

local db = mysqloo.connect( "123.456.789.0", "drake", "abc123", "database_name", 3306 )

function db:onConnected()

	print( "Database has connected!" )

	local q = self:query( "SELECT 5+5;" )
	function q:onSuccess( data )

		print( "Query successful!" )
		PrintTable( data )

	end

	function q:onError( err, sql )

		print( "Query errored!" )
		print( "Query:", sql )
		print( "Error:", err )

	end

	q:start()

end

function db:onConnectionFailed( err )

	print( "Connection to database failed!" )
	print( "Error:", err )

end

db:connect()

But I don’t know where, should I create a new file ? Or edit a file who already exists ?

I must write my private informations in “_MySQL.lua” who is in /garrysmod/gamemodes/darkrp/gamemode ? I don’t know…

Could you help me to go in the right direction ?

Thanks

DarkRP already has mysql support in MyQSL.lua or something, you just enter your information there and everything else is done for you.

Are you sure ?

Well, when i do that, my server is bugged, all players are in “joining/connecting” with no weapons, no money and a strange awful model.

I am sure that I enter the correct database’s informations.

Check for errors in the console.

Server (from FTP) doesn’t restart when I modify _MySQL.lua with private informations …

[editline]16th June 2013[/editline]

But when I try in singleplayer I have a lot of errors :



[ERROR] lua/includes/modules/mysqloo.lua:7: unexpected symbol near '='
  1. unknown - lua/includes/modules/mysqloo.lua:0


[ERROR] gamemodes/darkrp/gamemode/server/data.lua:7: Module not found!
  1. require - [C]:-1
   2. unknown - gamemodes/darkrp/gamemode/server/data.lua:7
    3. include - [C]:-1
     4. unknown - gamemodes/darkrp/gamemode/init.lua:103


[ERROR] gamemodes/darkrp/gamemode/fadmin/motd/sv_init.lua:15: attempt to call field 'SQLStr' (a nil value)
  1. unknown - gamemodes/darkrp/gamemode/fadmin/motd/sv_init.lua:15
   2. include - [C]:-1
    3. AddCSLuaFolder - gamemodes/darkrp/gamemode/shared/fadmin_darkrp.lua:39
     4. unknown - gamemodes/darkrp/gamemode/shared/fadmin_darkrp.lua:48
      5. include - [C]:-1
       6. unknown - gamemodes/darkrp/gamemode/init.lua:112


[ERROR] gamemodes/darkrp/gamemode/server/gamemode_functions.lua:885: attempt to call field 'ConnectToMySQL' (a nil value)
  1. unknown - gamemodes/darkrp/gamemode/server/gamemode_functions.lua:885

[ERROR] gamemodes/darkrp/gamemode/fadmin/access/sv_init.lua:191: attempt to call field 'SQLStr' (a nil value)
  1. v - gamemodes/darkrp/gamemode/fadmin/access/sv_init.lua:191
   2. unknown - lua/includes/modules/hook.lua:82


[ERROR] gamemodes/darkrp/gamemode/server/gamemode_functions.lua:606: attempt to call field 'RetrieveTeamSpawnPos' (a nil value)
  1. unknown - gamemodes/darkrp/gamemode/server/gamemode_functions.lua:6

Have you tried updating the SVN
**
Edit:** And you get those errors in Single Player because you don’t have the MySQLoo module on your client.

Could you explain me step by step what I had to do ?

Because, you said I only just have to modify _MySQL.lua from darkrp to succeed. But when I do I cannot restart my server … So there is something wrong somewhere …

(Sorry for my stupidity but I had to understand what’s wrong)

Ok, well, firstly just double check you have followed these instructions: http://forum.facepunch.com/showthread.php?t=1220537

Secondly, double check you have entered your MySQL info correctly. I have commented with an explanation what each thing is:

[LUA]
RP_MySQLConfig = {} – Ignore this line
–[[
Welcome to MySQL for DarkRP!
In this file you can find a manual for MySQL configuration and the MySQL config settings.
]]

RP_MySQLConfig.EnableMySQL = false – Set to true if you want to use an external MySQL database, false if you want to use the built in SQLite database (garrysmod/sv.db) of Garry’s mod.
– MAKE THIS TRUE

RP_MySQLConfig.Host = “127.0.0.1” – This is the IP address of the MySQL host. Make sure the IP address is correct and in quotation marks (" ")
– USUALLY THE IP ADDRESS OF YOUR WEBHOST (THIS MEANS YOU NEED A WEBSITE WHICH HAS MYSQL. FOR MORE INFO ON HOW TO SET UP A MYSQL DATABASE, GO HERE: http://www.interspire.com/content/2006/04/04/how-to-create-a-mysql-database-in-cpanel/)

RP_MySQLConfig.Username = “user” – This is the username to log in on the MySQL server.
– contact the owner of the server about the username and password. Make sure it’s in quotation marks! (" ")
– THE USERNAME; SELF EXPLANITORY

RP_MySQLConfig.Password = “password” – This is the Password to log in on the MySQL server,
– Everyone who has access to FTP on the server can read this password.
– Make sure you know who to trust. Make sure it’s in quotation marks (" ")
– THE PASSWORD; SELF EXPLANITORY

RP_MySQLConfig.Database_name = “DarkRP” – This is the name of the Database on the MySQL server. Contact the MySQL server host to find out what this is
– WHAT YOU CALLED YOUR MYSQL DATABASE

RP_MySQLConfig.Database_port = 3306 – This is the port of the MySQL server. Again, contact the MySQL server host if you don’t know this.
– KEEP THIS THE SAME

–[[
MANUAL!
HOW TO USE MySQL FOR DARKRP!
Download andyvincent’s/Drakehawke’s gm_MySQL OO module and read the guide here:
http://www.facepunch.com/showthread.php?t=1220537

WHAT TO DO IF YOU CAN’T GET IT TO WORK!
- There are always errors on the server, try if you can see those (with HLDS)
- the same errors are also in the logs if you can’t find the errors on the server.
the logs are at garrysmod/data/DarkRP_logs/ on the SERVER!
The MySQL lines in the log always precede with “MySQL Error:” (without the quotation marks)
- make sure the settings in this file (_MySQL.lua) are correct
- make sure the MySQL server is accessible from the outside world
]]
[/LUA]

If you’re still having trouble, please explain which line(s) confuse you.

Have you changed anything other than the MySQL info?

Try opening a support ticket with your game server and web hosting providers.

No there is a real problem i cannot check the errors because my server doesn’t even restart when I modify the file _MySQL.lua with my private informations. ( And I am sure the informations are correct)

I explain what I did :

  1. I pasted libmySQL.dll where are the files scrds

  2. I pasted gmsv_mysqloo_win32.dll in /garrysmod/lua/bin

  3. I modified _MySQL.lua

And I have to restart in order to apply the modifications and it doesn’ restart. When I write false in place of true in _MySQL.lua then it restarts.

My database is also used by a website peraphs that’s the problem ? (But If it is, I don’t understand how to link my server to my website if it is not on the same database)

Sorry but I am a beginner …