Can't connect to MySQL DB using LC Server & revIgniter

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
xyz
Posts: 30
Joined: Sat Feb 29, 2020 4:45 am

Can't connect to MySQL DB using LC Server & revIgniter

Post by xyz » Thu Apr 23, 2020 7:41 pm

EDIT: I think I found the reason. I set up a simple LC stack to connect to my MySQL DB and received an error saying that the client does not support the authentication protocol requested by the server. I don't know how to change that. :( I guess I'm off to the MySQL website.

---

I'm testing a local instance of LC server before I commit to LC server hosting.

I've installed LC community server and revIgniter. Everything seems to be working "like a champ."

I've successfully displayed views with "dynamic data", i.e., data I placed in gData[] in the controller.

Now I want to try sucking some data out of a MySQL DB. I set up MySQL on my machine and I can connect to it via MySQL Workbench. But, I cannot seem to connect using the revIgniter functions.

Using the "blog" example from the revIgniter user guide, I have this controller:

Code: Select all

<?lc

# PUT YOUR HANDLER NAMES  INTO THE GLOBAL gControllerHandlers AS A COMMA SEPARATED LIST
put "index,blog" into gControllerHandlers

command blog
  get rigLoadDatabase()
end blog

command index
  put "Tend Chickens,Get Chips,Pay Bills" into gData["toDoList"]

  put "My Real Title" into gData["title"]
  put "My To Do List" into gData["heading"]
  get rigLoadView("blogview")
end index
When I go to "localhost/blog" I get "Internal Server Error". When I comment out "get rigLoadDatabase()", my blogview displays properly.

I've configured the database settings in application/config/database.lc. All of the settings are correct. (Correct port, correct host, correct username & pw, etc.) It does not work regardless of how I have SSL set (i.e., either SSL turned on or off in both the database and my configuration file).

There must be some configuration error, but I cannot figure out what it is.

Any insight is appreciated.

Klaus
Posts: 14177
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Can't connect to MySQL DB using LC Server & revIgniter

Post by Klaus » Thu Apr 23, 2020 8:03 pm

Maybe closing the LC tag will help?

Code: Select all

<?lc
 ## your stuff here
?>

xyz
Posts: 30
Joined: Sat Feb 29, 2020 4:45 am

Re: Can't connect to MySQL DB using LC Server & revIgniter

Post by xyz » Thu Apr 23, 2020 8:07 pm

Actually, Ralf Bittner (I believe that is his name) recommends NOT closing the LC tag in server scripts. I just do what I am told to do!! :lol:
By the way you can omit the closing “?>” tags in LC server scripts.
Generally it is better to leave terminating "?>" tags off, this way whitespace
at the end of the script does not accidentally output content to the browser.

Klaus
Posts: 14177
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Can't connect to MySQL DB using LC Server & revIgniter

Post by Klaus » Thu Apr 23, 2020 8:29 pm

OK, that was just a shot in the dark... 8)

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10043
Joined: Sat Apr 08, 2006 7:05 am
Contact:

Re: Can't connect to MySQL DB using LC Server & revIgniter

Post by FourthWorld » Fri Apr 24, 2020 1:34 am

xyz wrote:
Thu Apr 23, 2020 8:07 pm
Actually, Ralf Bittner (I believe that is his name) recommends NOT closing the LC tag in server scripts. I just do what I am told to do!! :lol:
By the way you can omit the closing “?>” tags in LC server scripts.
Generally it is better to leave terminating "?>" tags off, this way whitespace
at the end of the script does not accidentally output content to the browser.
Under what circumstances could that happen?
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

xyz
Posts: 30
Joined: Sat Feb 29, 2020 4:45 am

Re: Can't connect to MySQL DB using LC Server & revIgniter

Post by xyz » Fri Apr 24, 2020 3:06 am

I don't know, Richard. I guess you would need to ask Ralf. BTW, I tried your 4wDevo plugin. Pretty cool. 8)

Do you have any idea why I am getting this error when I try to connect to the MySQL DB in a normal LC stack using revOpenDatabase? (Not using LC server or revIgniter)
Client does not support authentication protocol requested by server; consider upgrading MySQL client
I'm using LC v 9.5.1 and MySQL v 8.0.19 (MySQL Community Server) I looked up the issue on the MySQL site and it suggests that the problem lies with revOpenDatabase but that I could solve the problem by downgrading my security (by editing a MySQL config file). That seems like a lousy solution. But I did it anyway and that did not solve the problem.

Any insight would be appreciated.

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10043
Joined: Sat Apr 08, 2006 7:05 am
Contact:

Re: Can't connect to MySQL DB using LC Server & revIgniter

Post by FourthWorld » Fri Apr 24, 2020 3:21 am

xyz wrote:
Fri Apr 24, 2020 3:06 am
I don't know, Richard. I guess you would need to ask Ralf. BTW, I tried your 4wDevo plugin. Pretty cool. 8)
Thank you. Feel free to email requests and bugs if you have them.
Do you have any idea why I am getting this error when I try to connect to the MySQL DB in a normal LC stack using revOpenDatabase? (Not using LC server or revIgniter)
Is the DB on a remote machine?
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

xyz
Posts: 30
Joined: Sat Feb 29, 2020 4:45 am

Re: Can't connect to MySQL DB using LC Server & revIgniter

Post by xyz » Fri Apr 24, 2020 4:48 am

No, it is on the same machine.

I reinstalled MySQL, this time selecting the down-graded "legacy" authentication and it is now working with LC revOpenDatabase. Now I'll see if that was the problem with LC Server & revIgniter.

rabit
Posts: 40
Joined: Wed May 31, 2006 8:30 am

Re: Can't connect to MySQL DB using LC Server & revIgniter

Post by rabit » Sat Apr 25, 2020 1:52 am

FourthWorld wrote:
Fri Apr 24, 2020 1:34 am
xyz wrote:
Thu Apr 23, 2020 8:07 pm
Actually, Ralf Bittner (I believe that is his name) recommends NOT closing the LC tag in server scripts. I just do what I am told to do!! :lol:
By the way you can omit the closing “?>” tags in LC server scripts.
Generally it is better to leave terminating "?>" tags off, this way whitespace
at the end of the script does not accidentally output content to the browser.
Under what circumstances could that happen?
Here is the reason why it is better to leave terminating “?>” tags in handler libraries off:

The LC engine outputs necessary HTTP headers as well as custom headers,
then the content / output follows the headers.
Now what happens if you use a terminating “?>” tag? As long as you make sure
that the angle bracket is the last character everything works as expected.
But any character following the terminating tag, even a single space, will be output
before the actual content (generated by your script), including the default headers.
This means, in this case setting custom headers by script has no effect because
headers can be sent only once.
-- Ralf Bitter

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10043
Joined: Sat Apr 08, 2006 7:05 am
Contact:

Re: Can't connect to MySQL DB using LC Server & revIgniter

Post by FourthWorld » Sat Apr 25, 2020 2:52 am

Thanks, Ralf. That sounds like a bug. And if it applies when the last character is LF it's definitely a bug, since many editors enforce the old convention of ending things like config files with a blank line.

Do you know offhand if this has been reported?
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

rabit
Posts: 40
Joined: Wed May 31, 2006 8:30 am

Re: Can't connect to MySQL DB using LC Server & revIgniter

Post by rabit » Sat Apr 25, 2020 10:48 am

FourthWorld wrote:
Sat Apr 25, 2020 2:52 am
Thanks, Ralf. That sounds like a bug. And if it applies when the last character is LF it's definitely a bug, since many editors enforce the old convention of ending things like config files with a blank line.

Do you know offhand if this has been reported?

Richard, I really hate to disagree with you but it is not a bug. This is how it is supposed
to work. If a file contains only LC code the closing tag is definitely not needed.
The only reason the closing tag exists is to tell the engine which content needs to be parsed.
But this is only useful and even necessary for example in files which mix HTML with LC code.
In other cases the closing tags may cause unwanted effects.

So, the simple rule is: To be on the safe site don’t use code block terminating tags in files
which contain solely LC code.

By the way PHP works the same, at least if PHP doesn’t use some sort of
output buffering.
-- Ralf Bitter

ghettocottage
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 366
Joined: Tue Apr 10, 2012 9:18 am

Re: Can't connect to MySQL DB using LC Server & revIgniter

Post by ghettocottage » Sat Apr 25, 2020 3:28 pm

Code: Select all

..By the way PHP works the same, at least if PHP doesn’t use some sort of
output buffering.
yep.

When developing a Wordpress site or plugin and suddenly confronted with a white-screen-of-death, the first thing I will do is check for blank spaces and closing brackets at the end of the page.

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10043
Joined: Sat Apr 08, 2006 7:05 am
Contact:

Re: Can't connect to MySQL DB using LC Server & revIgniter

Post by FourthWorld » Sat Apr 25, 2020 6:56 pm

Thanks for the explanation, Ralf. After thinking about it for a bit it does make sense for libraries.

But then again, for libraries why even include the opening tag, why not just use a script-only stack?
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

rabit
Posts: 40
Joined: Wed May 31, 2006 8:30 am

Re: Can't connect to MySQL DB using LC Server & revIgniter

Post by rabit » Sat Apr 25, 2020 10:49 pm

FourthWorld wrote:
Sat Apr 25, 2020 6:56 pm
Thanks for the explanation, Ralf. After thinking about it for a bit it does make sense for libraries.

But then again, for libraries why even include the opening tag, why not just use a script-only stack?
I think CGI scripts and script-only stacks are not interchangeable and both have
their raison d'être. For example all revIgniter libraries which are loaded for the purpose
of providing code for a given task are script-only stacks. But revIgniter’s commands/functions,
which should be executed upon inclusion (right away, avoiding the necessity to include
libraryStack handlers) are CGI scripts. A good example of the latter are configuration files.
-- Ralf Bitter

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10043
Joined: Sat Apr 08, 2006 7:05 am
Contact:

Re: Can't connect to MySQL DB using LC Server & revIgniter

Post by FourthWorld » Sat Apr 25, 2020 11:35 pm

rabit wrote:
Sat Apr 25, 2020 10:49 pm
FourthWorld wrote:
Sat Apr 25, 2020 6:56 pm
Thanks for the explanation, Ralf. After thinking about it for a bit it does make sense for libraries.

But then again, for libraries why even include the opening tag, why not just use a script-only stack?
I think CGI scripts and script-only stacks are not interchangeable and both have
their raison d'être. For example all revIgniter libraries which are loaded for the purpose
of providing code for a given task are script-only stacks. But revIgniter’s commands/functions,
which should be executed upon inclusion (right away, avoiding the necessity to include
libraryStack handlers) are CGI scripts. A good example of the latter are configuration files.
Exactly. You specified libraries in your earlier explanation, and that helped me to understand the limited scope of the trailing closing tag as an issue, which is why I also specified libraries in my reply.

It seems we're on the same page.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

Post Reply