Page 1 of 1

access denied to MySQL database

Posted: Sat Jul 14, 2012 12:24 am
by James Little
Hi All,

We're unable to access our MySQL database using a LiveCode server script (.lc file). We can access the database using a desktop LiveCode stack. Here's our basic script:

Code: Select all

put "localhost" into tDatabaseAddress
put "dbname" into tDBname
put "xxxxxx_xxxx" into tDBuser
put "xxxxxxx" into tDBpass
put revOpenDatabase("MySQL", tDatabaseAddress, tDBname, tDBuser, tDBpass) into tDBconnection


Here's the error:

Access denied for user 'xxxxx'@'localhost' (using password: NO)

Any suggestions on what our problem is?


Regards,

Jim Little

Re: access denied to MySQL database

Posted: Sat Jul 14, 2012 6:26 pm
by Mark
Hi Jim,

I have the same problem if I use localhost. Try using the local IP address instead, e.g. 127.0.0.1. You can find the IP address with

Code: Select all

put hostnametoaddress("localhost")
Also, I wonder why MySQL reports "with password NO"? This should be "YES". Are you sure the user exists in MySQL and that a password for this user has been set?

Which version of LC do you use?

Kind regards,

Mark

Re: access denied to MySQL database

Posted: Sat Jul 14, 2012 11:47 pm
by James Little
Hi Mark,

Thanks for your suggestion. I did not know about the hostNameToAddress function. Unfortunately, that did not work as well.

I just discovered that I also get an "Access Denied" if I use the File Manager of cPanel. I think there is a fundamental problem with my On-Rev account. I emailed to On-Rev support.

Thanks again for your help.

Jim L.

Re: access denied to MySQL database

Posted: Sat Jul 14, 2012 11:56 pm
by Mark
Jim,

Just a hunch... provided that the user exists, what happens if you provide an empty password?

Mark

Re: access denied to MySQL database

Posted: Sun Jul 15, 2012 4:36 am
by James Little
SOLVED!

There were blank spaces after several local variables. Thus, I had written (tDBname ) rather than (tDBname). This extra space after variable names was the cause of most of my grief.

A secondary problem was case-sensitivity for a table name. Thus the db.table was (xxxx_myDB.myTableName) but I had written (xxxx_myDB.mytablename).

Jim L.

Re: access denied to MySQL database

Posted: Fri Jun 14, 2013 8:22 am
by johnhb
I am trying to connect to a MYSQL database on a website that I manage.
Here is the code I am using from a simple button in LC.
on mouseUp
global gDataConnectionID
put revOpenDatabase("mysql", "www.wendoureerotary.org.au", "wendoure_xxxxxx", "wendoure_johnhb", "xxxxxxxx")into dataConnectionID
if dataConnectionID is a number then
put dataConnectionID into field "fdbID"
else
answer dataConnectionID
end if
end mouseUp.

And I get the error message:
Access denied for user:wendoure_johnhb@xxx.xxx.xxx.xxx (Using password YES).
I know the table name, user and password are correct as I have them in a php script that I use to access the database in the website.
Anyone know what I am doing wrong?

Re: access denied to MySQL database

Posted: Fri Jun 14, 2013 10:00 am
by bangkok
johnhb wrote: I know the table name, user and password are correct as I have them in a php script that I use to access the database in the website.
Anyone know what I am doing wrong?
It seems that you try from a local LC (button) to access a remote DB.

You could have 2 problems :
-the MYSQL server doesn't accept remote connexions

-the user has not the right parameters : wendoure_johnhb@%

the wild card % meaning that any IP will be accepted by MySQL Server.

Re: access denied to MySQL database

Posted: Mon Jun 17, 2013 5:08 am
by johnhb
Thank you bangkok

Re: access denied to MySQL database

Posted: Sat Jan 21, 2017 1:05 pm
by greeneye
Here is another possible solution for you... I just started with LiveCode but have many years behind me with other developer languages.

I got tricked by my eyes, you see what you want to see...

Dev environment in this case: Win 10, MySQL 5.7 local install, followed standard config on this to test some stuff (most is "next-next-finish" installation).

Anyway, this is the code I got stuck on:

put revOpenDatabase("MySQL", tDatabaseAddress, tDatabaseName, tDatabaseUser, tDatabasePassword) into tResult

Got connection, but got "access denied 'myuser' on 'mydatabase'

Checked the connection through MySQL command line ( check this: Search online, I cannot post links it seams?), and that worked. Also in workbench the new user worked. Did a restart of the service and it did not help (did not expect it to do so, but had to try..).

THEN I ran a debug (should have done that in the first place).

In the debug window my variable tDatabasePassword = tDatabasePassword. Hmm.. why? The reason was an error in my variable section. In my variable declarations tDatabasePassword was now named tDatabasePasswordput (put at the end), because of a previous stupid typo / editing.

So.. based on this I can tell that livecode is not to picky on variable names when used and not declared properly. Sure this can be set in the IDE but I am not there yet.

Good luck! :)