mySQL with MAMP won't connect
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
-
- Livecode Opensource Backer
- Posts: 78
- Joined: Sat Apr 17, 2010 9:21 am
mySQL with MAMP won't connect
I have developed a database system in SQLite which works fine.
But now I need to have it worked through mysql server. So I installed MAMP Pro.
Set up the mysql database and want to acces the database through MAMP pro.
So I made the following connection script:
on mouseUp
global gConID, tList, tNr
local tDBAddress, tDBName, tUser, tPassword, tPath
local tResult
put "localhost:8889" into tDBAddress
put "mams" into tDBName
put "root@localhost" into tUser
put "root" into tPassword
put revOpenDatabase(MySQL, tDBAddress, tDBName, tUser, tPassword) into tResult
if tResult is a number then
put tResult into gConID
answer info "Connected to the database." & cr & "Connection ID = " & gConID
else
put empty into gConnectionID
answer error "Unable to connect to the database:" & cr & tResult
end if
end mouseUp
I tried all kinds of things like changing the localhost to the port nr. etc. Looked up all the posts here, but I don't get any connection.
Maybe I did something wrong in the script, but I don't see it.
Can someone advice me?
Thanks
Rob van der Sloot
But now I need to have it worked through mysql server. So I installed MAMP Pro.
Set up the mysql database and want to acces the database through MAMP pro.
So I made the following connection script:
on mouseUp
global gConID, tList, tNr
local tDBAddress, tDBName, tUser, tPassword, tPath
local tResult
put "localhost:8889" into tDBAddress
put "mams" into tDBName
put "root@localhost" into tUser
put "root" into tPassword
put revOpenDatabase(MySQL, tDBAddress, tDBName, tUser, tPassword) into tResult
if tResult is a number then
put tResult into gConID
answer info "Connected to the database." & cr & "Connection ID = " & gConID
else
put empty into gConnectionID
answer error "Unable to connect to the database:" & cr & tResult
end if
end mouseUp
I tried all kinds of things like changing the localhost to the port nr. etc. Looked up all the posts here, but I don't get any connection.
Maybe I did something wrong in the script, but I don't see it.
Can someone advice me?
Thanks
Rob van der Sloot
Re: mySQL with MAMP won't connect
{EDIT] First thing to try is putting quotes around the db type string, as this is a string literal, not a variable:
put revOpenDatabase("MySQL", tDBAddress, tDBName, tUser, tPassword) into tResult
[/EDIT]
Based on experiences of mysql on Linux hosted web servers, I would try changing localhost to 127.0.0.1 in the database address. Maybe also you might not need to supply the port number if the connection is using the defaults. Otherwise do you get phpmyadmin in your mamp setup? Check with that or whatever setup tools to confirm the credentials, maybe just "root" without the @localhost. (That being said, after testing you can connect, you should create a new database user account and use that instead of root.)
put revOpenDatabase("MySQL", tDBAddress, tDBName, tUser, tPassword) into tResult
[/EDIT]
Based on experiences of mysql on Linux hosted web servers, I would try changing localhost to 127.0.0.1 in the database address. Maybe also you might not need to supply the port number if the connection is using the defaults. Otherwise do you get phpmyadmin in your mamp setup? Check with that or whatever setup tools to confirm the credentials, maybe just "root" without the @localhost. (That being said, after testing you can connect, you should create a new database user account and use that instead of root.)
-
- Livecode Opensource Backer
- Posts: 78
- Joined: Sat Apr 17, 2010 9:21 am
Re: mySQL with MAMP won't connect
OK, thanks I will work on that later.
At the moment I have the mySQL connection stablished in a network and that works ok.
So for the time being the problem is solved.
One other little question: When I do:
put revOpenDatabase(MySQL, tDBAddress, tDBName, tUser, tPassword)
put "SELECT * FROM " & table into tSQL
put revDataFromQuery(,,gConID,tSQL) into tList
set the dgText of group "dgClient" to tList
I get the messagebox opened with the connection number automatically
How can that be solved?
At the moment I have the mySQL connection stablished in a network and that works ok.
So for the time being the problem is solved.
One other little question: When I do:
put revOpenDatabase(MySQL, tDBAddress, tDBName, tUser, tPassword)
put "SELECT * FROM " & table into tSQL
put revDataFromQuery(,,gConID,tSQL) into tList
set the dgText of group "dgClient" to tList
I get the messagebox opened with the connection number automatically
How can that be solved?
Re: mySQL with MAMP won't connect
Your first statement is "put...." without "into gConnID" hence the output goes to the message box.
-
- Livecode Opensource Backer
- Posts: 78
- Joined: Sat Apr 17, 2010 9:21 am
Re: mySQL with MAMP won't connect
I haven't been able to get LiveCode able to connect to the SQL database through MAMP Pro. I tried everything I can think off, but no succes at all. I also installed mySQLserver and also tried Wampserver. But that is all going far above my expertice.
As said I first setup the LC application with SQLite.
The conversion from SQLite to mySQL on a remote server took some hurdels, but eventually it worked fine.
But because that server is not in my own office at home, I decided to set the database from MySQL back into a SQLite database. The maine conversion issue was that all the names of the tables are now in underscore, that was the requirement from MAMP server at my clients remote setup. So what I did was change all the captital table names in LC to underscore. And that worked fine with mySQL. So I reorganised the SQLite database also with tables only in underscores. Which also works fine if I do the sql statement in the SQLite screen.
But now when I do from LiveCode the query, like: SELECT * FROM tc01_technicians I don't get what I want. First of course the connection to the Database and as third step: put revDataFromQuery(,,gConID,tSQL) into tList.
And now here also nothing happens, as before it worked fine without any problem SQLite. I have checked this revDataFromQuery(,,gConID,tSQL) statement on diffent locations in my app. And it seems that on statements which worked in mYSQL, they are suddenly not working with SQLite anymore in LiveCode.
Someone any idea how to get around this, or do I need to build seperate cards for mySQL and SQLite?
thanks
Rob van der Sloot
As said I first setup the LC application with SQLite.
The conversion from SQLite to mySQL on a remote server took some hurdels, but eventually it worked fine.
But because that server is not in my own office at home, I decided to set the database from MySQL back into a SQLite database. The maine conversion issue was that all the names of the tables are now in underscore, that was the requirement from MAMP server at my clients remote setup. So what I did was change all the captital table names in LC to underscore. And that worked fine with mySQL. So I reorganised the SQLite database also with tables only in underscores. Which also works fine if I do the sql statement in the SQLite screen.
But now when I do from LiveCode the query, like: SELECT * FROM tc01_technicians I don't get what I want. First of course the connection to the Database and as third step: put revDataFromQuery(,,gConID,tSQL) into tList.
And now here also nothing happens, as before it worked fine without any problem SQLite. I have checked this revDataFromQuery(,,gConID,tSQL) statement on diffent locations in my app. And it seems that on statements which worked in mYSQL, they are suddenly not working with SQLite anymore in LiveCode.
Someone any idea how to get around this, or do I need to build seperate cards for mySQL and SQLite?
thanks
Rob van der Sloot
Re: mySQL with MAMP won't connect
Hi Rob,
as far as i know and if i'm correct, do a search on google when to use ticks ` (mostly left to the 1 on your keyboard) and when to use quotes ' or double quotes ".
When using numbers in your table names you need to use ticks around them (normally in PHP) `tc01_technicians`, this could be an issue.
Did you use this command in your script to execute everything?
revExecuteSQL connectionID,tSQL
Check the dictionary on it.
Also are you sure the portnr is correct? normally with MAMP and those test-servers it is 8080 or just port 80 as local host.
as far as i know and if i'm correct, do a search on google when to use ticks ` (mostly left to the 1 on your keyboard) and when to use quotes ' or double quotes ".
When using numbers in your table names you need to use ticks around them (normally in PHP) `tc01_technicians`, this could be an issue.
Did you use this command in your script to execute everything?
revExecuteSQL connectionID,tSQL
Check the dictionary on it.
Also are you sure the portnr is correct? normally with MAMP and those test-servers it is 8080 or just port 80 as local host.
Re: mySQL with MAMP won't connect
Another thing i just saw in your script.
Most of the time those standalone servers like Mamp, xamp or easyphp do NOT use a password to connect to the MySQL server, so try to connect without that root password.
Most of the time those standalone servers like Mamp, xamp or easyphp do NOT use a password to connect to the MySQL server, so try to connect without that root password.