-2

I am trying to Connect my livecode app with the Mysql server.I works well when i use it on localserver.But When i try to connect it with Live Mysql database. Its gives an error

access denied for user 'myusername'localhost'(using password='YES').

I am using this for connecting:

put "localhost" into tDatabaseAddress
put "dbname" into tDatabaseName
put "myusername" into tDatabaseUser
put "mypassword" into tDatabasePassword
put revOpenDatabase("MySQL", tDatabaseAddress, tDatabaseName, tDatabaseUser, tDatabasePassword) into tDatabaseID

Please help. How can I resolve this?

Mark
  • 2,380
  • 11
  • 29
  • 49
Rohit Bhardwaj
  • 269
  • 4
  • 20
  • 1
    error message is very explicit... – Mitch Wheat Aug 10 '13 at 09:10
  • If you have just added a user and password to access the database, make sure the grant tables are reloaded by using 'FLUSH PRIVILEGES' or you can restart the db server. – splash21 Aug 10 '13 at 09:31
  • 2
    "It works well when i use it on *localserver*.But [not] When i try to connect it with *Live Mysql database*." It is quite surprising the the DB address is still *localhost* according to `tDatabaseAddress` while connecting to you "live DB", which, if I understand it well, is *not* local... – Sylvain Leroux Aug 10 '13 at 09:41
  • i can connect with live server by localhost as database address in php website.So i was trying the same with livecode.But i am able to connect with the Mysql on live server. – Rohit Bhardwaj Aug 12 '13 at 05:31

1 Answers1

0

Many web hosting companies don't allow direct remote access to the MySQL database. You need to use PHP as an intermediary.

Mark
  • 2,380
  • 11
  • 29
  • 49
  • If above is the reason then what should i do to resolve this?..actualy firstly i was trying to use sqlite as cloud base.But didnot get success as sqlite is just for local storage.Now i move to mysql, but then it too getting problems in connecting on live.Really hard!! – Rohit Bhardwaj Aug 12 '13 at 05:45
  • You have to write PHP script that LiveCode can connect to by posting multi-part form data. This article http://qery.us/3y7 describes a possible solution (but no syntax or downloads). The picture is a LiveCode stack and it connects to a PHP site. You can also do this with SQLite, since your server probably has SQLite3 on it, but you may need to ask the hosting company to enable command line access for PHP (or do this in a php.ini file). You could contact Economy-x-Talk for more info. – Mark Aug 12 '13 at 09:16
  • I am looking in this lesson..http://lessons.runrev.com/s/lessons/m/4071/l/7003-connecting-to-a-mysql-database .It is working fine ,in this runrev.com is database address and connecting with livecode.But i am not getting that in case of with my database.:( – Rohit Bhardwaj Aug 12 '13 at 09:48
  • That lesson doesn't apply to your situation. – Mark Aug 12 '13 at 10:58
  • Then how to use PHP script as intermediary?...Can you please give a link or reference, which can make it possible – Rohit Bhardwaj Aug 12 '13 at 11:02
  • First, you will have to learn PHP. Once you know that, it'll be obvious. I don't think that this is the right place to give a complete PHP course :-) Start here http://www.w3schools.com/php/default.asp . Actually, one assumes that programmers on Stackoverflow already know about W3Schools. Make sure to check it out before you ask any more questions. – Mark Aug 12 '13 at 13:43
  • hehehehe..This was not My question,Can i use PHP script in Livecode to connect with mysql or somewhere else i need to write my PHP code.As you said to use PHP as intermediary ,so i wanted you to provide me some refernece if you have, where PHP script used in livecode. – Rohit Bhardwaj Aug 13 '13 at 07:42
  • You don't use PHP in LiveCode. From the website, to which I linked in my previous comment: "PHP is a server scripting language, and is a powerful tool for making dynamic and interactive Web pages." – Mark Aug 13 '13 at 16:32
  • I got this thing..But Can you please explain how my condition is different from this http://lessons.runrev.com/s/lessons/m/4071/l/7003-connecting-to-a-mysql-database. As i can too connect with runrev.com database. In this http://forums.runrev.com/viewtopic.php?f=12&t=12435 , they too trying to use same procedure.Nobody is using the php as script. – Rohit Bhardwaj Aug 20 '13 at 12:55
  • In the lesson and the forum, either one has direct access to the remote database or the database is installed locally. This is a permissions thing. If you try to access a remote database, the web hosting company decides whether you can do this or not. Sometimes, you can change this option in your CPanel or Plesk. If you have a dedicated server, you can usually control this yourself. – Mark Aug 20 '13 at 16:30
  • I have a server on which i have hosted some php websites's databases.It works fine for them.Can you please let me know the way i can change something in Cpanel to make it compatible with livecode.I am really stuck with this. If there is some way to use Sqlite as remote database then please let me that too.. – Rohit Bhardwaj Aug 21 '13 at 04:33
  • I have done some changes in Cpanel.There is an option for "remote Mysql".In this it allows me to put my IP address to enable remote access for my Ip.I did that and it worked with me.I am now able to connect with remote mysql from my application.But it is not working when i am trying to create build and use it in my android phone.Is it because it just enabled for my PC's IP? So if i need to enable this for all ips what should i do? – Rohit Bhardwaj Aug 21 '13 at 09:52
  • You may use a wildcard like * or % to allow all IP's. Mind that this is unsafe. Hackers have standard tools to find such databases and get access to them. You should not do this. – Mark Aug 21 '13 at 09:55
  • I can try other things like as you told me about PHP.But due to time constraint i have to show some thing that will help me stay on my job otherwise i will throw out of my chair hehehe...Apart of this , i tried % and *, but it didnot work for it. – Rohit Bhardwaj Aug 21 '13 at 10:44
  • Ask your web hosting company. – Mark Aug 21 '13 at 11:31