Discovery pattern extension for MySQL
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-23-2022 05:46 AM
Hello all, I need a help with extended pattern "My SQL server On Windows and Linux".
I created an application credentials for MySQL database and used them in pattern:
Then I need the following commandline to connect to MySQL:
And I got the error:
I checked that username is right in error message.
If I tried this: "mysql -u" + "$$username$$" + " -p" + "$$password$$" + "--skip-column-names -e \"SHOW DATABASES;\""
I got another error:
Database administrator checked the strings on their side and it works fine for them:
- RDP to the Midserver
- Launch a putty session and connect to the discovered server (used same ssh private key as the one entered in ServiceNow credentials)
- Execute the query from command line : mysql –u username –ppassword ….
And he got the list of database.
Can you please help me why this error can be? Maybe we need additional rights or something else.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-25-2022 06:51 AM
Hi @Sofia1994
It seems your syntax is incorrect as you directly use mysql command, on server it might not be added to system path, always need to try from the directory where the mysql is located. Also some syntactical errors also observed comparing with OOB code.
Please refer the identification section of same pattern and you can find some existing steps that use applicative credentials and make use of the same temp variables as you are just extending the pattern. Use the OOB steps as reference and you should be able to achieve this simpler.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-25-2022 03:24 PM
Hello @SiD2,
I tried all commandlines from pattern I found:
1. "su - " + $userid + " -c '" + $ExecutableDir + "mysql --user=" + "$$username$$" + " --password=" + "'$$password$$'" + " --port=" + $jdbc_port + " --skip-column-names --silent --execute=\'SHOW ENGINE NDB STATUS;;\''"
2. $mysql + " --user=" + "$$username$$" + " --password=" + "'$$password$$'" + " --port=" + $jdbc_port + " --skip-column-names --silent --execute=\"SHOW ENGINE NDB STATUS\""
I tried them both with
1. "su - " + $userid + " -c '" + $ExecutableDir + "mysql --user=" + "$$username$$" + " --password=" + "'$$password$$'" + " --port=" + $jdbc_port + " --skip-column-names --silent --execute=\'SHOW DATABASES;;\''"
2. $mysql + " --user=" + "$$username$$" + " --password=" + "'$$password$$'" + " --port=" + $jdbc_port + " --skip-column-names --silent --execute=\'SHOW DATABASES\""
And I received the error about end of file, I removed ";;" in the first case and I received error about end of file: "...failed with status 1. bash: -c: line 0: unexpected EOF while looking for matching `'' bash: -c: line 1: syntax error: unexpected end of file"
And OOB pattern commandlines also show me the same error.
I checked that all variables are populated.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-27-2022 09:48 PM
Hi @Sofia1994
Hmm, these are pretty confusing/complex sometimes. What I observed so far was due to multiple incorrect attempts also some times user gets locked and doesn't throw proper errors.
I would suggest taking the exact command from the debugger or discovery log after the variables are filled in and try same from the actual host. You can make necessary corrections if required [till it works] on the host machine and come back to pattern and address those corrections carefully with variables.
Also I hope in the pattern step you selected the advanced checkbox and target CI type below the command. Also remove the change user step in the pattern as you mentioned in the screenshot, it's not required.
If you weren't able to fix even after all this, I would recommend to create a case with SNOW so that someone can assist you.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-30-2022 02:12 PM
Hello @SiD2 ,
I executed command line in "Command prompt" and it works. I executed ps1 script with username and password in "Command prompt", it also works.
I checked username with string "$$username$$" and I saw the following error:
It works before and I saw username in output, but now it doesn't work. I created extension from scratch, and I see the same error. Also I tried with change/unchange user, it doesn't work:
We have following credentials (applicative):
And JDBC:
And I don't see anything in google how to fix this problem.