access denied to MySQL database

Creating desktop or client-server database solutions?

Moderators: Klaus, FourthWorld, heatherlaine, robinmiller, kevinmiller

Post Reply
James Little
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 47
Joined: Thu Apr 27, 2006 11:19 pm
Location: Seattle

access denied to MySQL database

Post by James Little » Sat Jul 14, 2012 12:24 am

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

Mark
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 5132
Joined: Thu Feb 23, 2006 9:24 pm
Contact:

Re: access denied to MySQL database

Post by Mark » Sat Jul 14, 2012 6:26 pm

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
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode

James Little
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 47
Joined: Thu Apr 27, 2006 11:19 pm
Location: Seattle

Re: access denied to MySQL database

Post by James Little » Sat Jul 14, 2012 11:47 pm

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.

Mark
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 5132
Joined: Thu Feb 23, 2006 9:24 pm
Contact:

Re: access denied to MySQL database

Post by Mark » Sat Jul 14, 2012 11:56 pm

Jim,

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

Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode

James Little
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 47
Joined: Thu Apr 27, 2006 11:19 pm
Location: Seattle

Re: access denied to MySQL database

Post by James Little » Sun Jul 15, 2012 4:36 am

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.

johnhb
Posts: 8
Joined: Wed May 29, 2013 2:16 am

Re: access denied to MySQL database

Post by johnhb » Fri Jun 14, 2013 8:22 am

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?

bangkok
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 825
Joined: Fri Aug 15, 2008 7:15 am

Re: access denied to MySQL database

Post by bangkok » Fri Jun 14, 2013 10:00 am

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.

johnhb
Posts: 8
Joined: Wed May 29, 2013 2:16 am

Re: access denied to MySQL database

Post by johnhb » Mon Jun 17, 2013 5:08 am

Thank you bangkok

greeneye
Posts: 1
Joined: Sat Jan 21, 2017 12:48 pm

Re: access denied to MySQL database

Post by greeneye » Sat Jan 21, 2017 1:05 pm

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! :)
Attachments
connecting issue.gif
Some more details

Post Reply

Return to “Databases”