View Full Version : Mysql connect

04/12/2016, 03:56 PM

How can i connect to mysql to my computer localhost! Must be easy thanks

04/12/2016, 04:24 PM
Only put localhost

04/12/2016, 04:24 PM
I found this very useful when I had trouble at first learning MySQL: http://wiki.sa-mp.com/wiki/MySQL/R33#mysql_connect

Find mysql_connect and look at the example there. To connect specifically to localhost you can use "localhost" or like it said in that example. After connecting use a test with printf to see if you connected successfully, for instance something like this:

if (!mysql_errno(MySQL))
printf("MySQL connected properly!");

Another tip is to download a gamemode that is using MySQL, find one that uses threading and non-threading (mysql_tquery vs mysql_query). That way you will learn both ways of when you can afford using a multi-threading scenario (which is preferred, using threads = you can "perform" multiple things at once) but also learn how to use normal query's when you shouldn't wait on the main thread. Cheers mate good luck!

04/12/2016, 04:25 PM