Jump to content

[TUT] MySQL Configure - UPDATED 2012-04-08


Todd

Recommended Posts

This is outdated. It is recommended you use the internal db* functions instead - Woovie

https://wiki.multitheftauto.com/wiki/Se ... _functions

MySQL Server Configure

1. WHAT IS MySQL?

MySQL ( My Sequel ) - is the world's most used relational database management system (RDBMS) that runs as a server providing multi-user access to a number of databases.

LINKS:

[*] MySql on official Multi Theft Auto wiki

[*] Official Multi Theft Auto plugins

From THAT LIST you will need only these two files:

[*] mta_mysql.dll and libmysql.dll for Windows

[*] mta_mysql.so for Linux

2. HOW TO INSTALL MODULES?

* When you've got Windows:

After module download you have to paste libmysql.dll into the server folder ( for example here C:\Program Files\MTA San Andreas\server ). When you've already done it go to mods -> deathmatch and create there folder called "modules". And to the modules folder you have to put mta_mysql.dll file. After that you have to edit mtaserver.conf file and add this line:

"mta_mysql.dll" />  

REMEMBER!: It have to be between and

* When you've got Linux:

Just instead mta_mysql.dll you have to paste mta_mysql.so, and add this line into mtaserver.conf file:

"mta_mysql.so" />  

3. Useful functions

[url=https://wiki.multitheftauto.com/wiki/Modules/MTA-MySQL/mysql_connect]mysql_connect[/url](hostname, username, password, database) 

[url=https://wiki.multitheftauto.com/wiki/Modules/MTA-MySQL/mysql_query]mysql_query[/url](handler, query) 

4. How to create server MySQL on personal computer?

You will need:

[*] XAMPP Program

1. Download, Install and run.

You will see something like that:

xmp.png

2. Now you have to click START button near MySQL label to run MySQL server.

3. As you see now you can use admin option but you have to run Apache server before you will get all permissions in that option.

4. When you've done it, you can click Admin... button near MySQL then PHPMyAdmin opens.

5. and you can now add new user without any problems. ENJOY! that's all

WARNING:

When you will turn svc option "on" near all servers then with computer run server will turn on automatically!

UPDATE: 2012-04-08

4. How to create server MySQL with website hosting?

1. First you have to create MySQL server on website hosting. MySQL can not work properly when you are running on personal computer with dynamic IP. I advise you to use 000webhost , you can use your own hosting but with MySQL database!

HOW TO CREATE ACCOUNT ON 000webhost.com and MAKE MySQL database?

It's simple if you know how to do that you can skip to the point 2 but if you don't you can stay here.

Let's start:

I. press sign up button

II. use free subdomain you don't need to use own domain if you have.

III. your name can be fictional

IV. your email must be REAL cause you will get the access to the site by activation message

V. now set your password

VI. agree terms and go on.

VII. accept mail activation and wait for site activate

VIII. go to cPanel and find MySQL icon, click on it and create new database

AFTER THAT YOU WILL GET THE DATA FOR YOUR NEW DATABASE

YOU CAN OPERATE YOUR DB BY PHPMYADMIN WHICH CAN BE FOUND ALSO IN cPANEL

FOR EXAMPLE YOUR DATA IS:

hostname : mysql116.000webhost.com

dbname: 13213_mta

username: 21313_mtauser

password: asshole123

2. Ok you have got MySQL database but how to include it to our server?

- First please download server files needed to run MySQL

server.zip

server.zip for german hosting

- Now unpack it to the MTA folder and replace server folder with my files.

- Now edit settings.xml file // don't be noob it's easy to found it!

   -- MySQL Configuration --> 
    "@sql.username" value="username for db" /> 
    "@sql.password" value="password for db" /> 
    "@sql.database" value="database name" /> 
    "@sql.hostname" value="localhost" /> 
    "@sql.port" value="3306" /> 
    "@sql.socket" value="/var/run/mysql/mysql.sock" /> 

try to use /var/lib/mysql/mysql.sock if you are using other hosting like german.

now if your data is

hostname : mysql116.000webhost.com

dbname: 13213_mta

username: 21313_mtauser

password: asshole123

try to change username, database name and password , don't change hostname. localhost must stay!

so it have to look like that now

   -- MySQL Configuration --> 
    "@sql.username" value="21313_mtauser" /> 
    "@sql.password" value="asshole123" /> 
    "@sql.database" value="13213_mta" /> 
    "@sql.hostname" value="localhost" /> 
    "@sql.port" value="3306" /> 
    "@sql.socket" value="/var/run/mysql/mysql.sock" /> 

now let's edit mysql.lua file which can be found in sql folder.

local function connect( ) 
-- retrieve the settings 
local server = get( "server" ) or "localhost" -- dont change it 
local user = get( "user" ) or "user name for db" 
local password = get( "password" ) or "password for db" 
local db = get( "database" ) or "database name" 
local port = get( "port" ) or 3306 
local socket = get( "socket" ) or nil 

now your mysql.lua file should look like that: ( but change it to your own data ... )

local function connect( ) 
-- retrieve the settings 
local server = get( "server" ) or "localhost" -- dont change it 
local user = get( "user" ) or "21313_mtauser" 
local password = get( "password" ) or "asshole123" 
local db = get( "database" ) or "13213_mta" 
local port = get( "port" ) or 3306 
local socket = get( "socket" ) or nil 

END.

I WILL UPDATE THIS TUTORIAL LATER

if you have got any reservations/suggestions/problems then just tell me.

Edited by Guest
Link to comment
  • Replies 61
  • Created
  • Last Reply

Top Posters In This Topic

Port is always 3306?

And the other question is , at 000webhost says :

"Important: MySQL Host for any database in this account is mysql5.000webhost.com , do not use localhost!"

Yes, port is always 33006, but you can change it.

"Important: MySQL Host for any database in this account is mysql5.000webhost.com , do not use localhost!"

And?

Link to comment

And the problem is that I can't connect with 000webhost

I tried with localhost and mysql5.000webhost.com but it doesnt work.

What can be the problem?

  
local server = get( "server" ) or "localhost" -- dont change it 
local user = get( "user" ) or "a3099655_edikosh" 
local password = get( "password" ) or "pizzacon123" 
local db = get( "database" ) or "a3099655_mtadb" 
local port = get( "port" ) or 33006 
local socket = get( "socket" ) or nil 
  

Link to comment
And the problem is that I can't connect with 000webhost

I tried with localhost and mysql5.000webhost.com but it doesnt work.

What can be the problem?

  
local server = get( "server" ) or "localhost" -- if you host the database on any other machine than the one hosting the actaul mta server, this comment is stupid. 
local user = get( "user" ) or "a3099655_edikosh" 
local password = get( "password" ) or "pizzacon123" 
local db = get( "database" ) or "a3099655_mtadb" 
local port = get( "port" ) or 33006 
local socket = get( "socket" ) or nil 
  

I hope you've seen

You have go to our members' area, enter the control panel and click on the 'MySQL' icon. Your MySQL hostname will be listed there.

Important! Never use 'localhost' as your MySQL hostname here or you will get access denied errors!

And tried with

local server = get( "server" ) or "the_given_hostname_here" -- if you host the database on any other machine than the one hosting the actaul mta server, this comment is stupid. 

Link to comment
  • 2 months later...

Your code is wrong, Todd.

local function connect( ) 
-- retrieve the settings 
local server = get( "server" ) or "localhost" -- dont change it 
local user = get( "user" ) or "21313_mtauser" 
local password = get( "password" ) or "asshole123" 
local db = get( "database" ) or "13213_mta" 
local port = get( "port" ) or 3306 
local socket = get( "socket" ) or nil 

You forgot an 'end' on the final.

local function connect( ) 
    -- retrieve the settings 
    local server = get( "server" ) or "localhost" -- dont change it 
    local user = get( "user" ) or "21313_mtauser" 
    local password = get( "password" ) or "asshole123" 
    local db = get( "database" ) or "13213_mta" 
    local port = get( "port" ) or 3306 
    local socket = get( "socket" ) or nil 
end 

Edited by Guest
Link to comment

This tutorial looks pretty well and explains all the basic things in order to use MySQL on your server. Sometimes your English is not the best, though still comprehensible.

I would personally add one thing to your tutorial: On several Linux-based systems such as Debian or Ubuntu "localhost" does not work due to problems with the host configuration of MySQL. In this case use "127.0.0.1" instead of "localhost".

Btw: To be honest I do not like XAMPP. I suggest using WAMP which is easier to manage and causes less problems in general.

Good job!

Link to comment
  • 4 weeks later...

hostname : mysql116.000webhost.com

dbname: 13213_mta

username: 21313_mtauser

password: asshole123

  
local function connect( ) 
-- retrieve the settings 
local server = get( "mysql116.000webhost.com" ) or "localhost" -- CHANGE IT!!! 
local user = get( "user" ) or "21313_mtauser" 
local password = get( "password" ) or "asshole123" 
local db = get( "database" ) or "13213_mta" 
local port = get( "port" ) or 3306 
local socket = get( "socket" ) or nil 
end 
  

you have to add servername if you don't do that it will not work.

Link to comment

my god

  
local function connect( ) 
-- retrieve the settings 
local server ="mysql116.000webhost.com" 
local user = g"21313_mtauser" 
local password ="asshole123" 
local db =  "13213_mta" 
local port =  3306 
local socket = nil 
end 
  

Link to comment
my god
  
local function connect( ) 
-- retrieve the settings 
local server ="mysql116.000webhost.com" 
local user = g"21313_mtauser" 
local password ="asshole123" 
local db =  "13213_mta" 
local port =  3306 
local socket = nil 
end 
  

  
local function connect( ) 
-- retrieve the settings 
local server ="mysql116.000webhost.com" 
local user = "21313_mtauser" 
local password ="asshole123" 
local db =  "13213_mta" 
local port =  3306 
local socket = nil 
end 
  

Link to comment

I have a problem , first time i opened mysql and apache [not for web hosting ] and after that i went to sleep and i closed my laptop when i woke up and turn my laptop on i pressed on " Xampp control panel " then i saw the MySQL is running but the Apache isn't i pressed on the start button for Apache and it don't work , i keeped trying it opens and after 2secs it close , help please?

EDIT : I fixed it i closed skype and it works [ it may be helpful so i keeped the massege ] :)

Edited by Guest
Link to comment
Guest
This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.

×
×
  • Create New...