Ping website from MySQL Stored Procedure - mysql

I'm hosted a MySql database on Amazon RDS, and I'm looking to create a Stored Procedure that will ping my NAS at home and log the results to a table. I'm looking to create a log of my home internet outages.
I'm new to MySql and have no idea how to ping something from a Stored Procedure, and every search on google appears to be on how to ping a MySql server, not how to ping from a MySql stored procedure.
In mssql I can ping using the following method:
DECLARE #pingAddress VARCHAR(200) = 'ping www.google.ca'
EXEC master..xp_cmdshell #pingAddress
Is there anyway to achieve the same affect in MySql?

You shouldn't ping or do anything else outside the database in a stored procedure. Stored procedures are for manipulating data in MySQL.
If you want to log your home internet outages, there are services that do that for you, for example https://www.pingdom.com/free
If you prefer to do it yourself with custom code, write an application and host it on a small EC2 instance, or else run a Lambda function on a schedule or something like that.
Here's a blog about how one person did it with a Lambda: https://medium.com/#nzoschke/http-service-health-monitor-w-lambda-a9f475abbbf4

In a native MySQL unextended by user-defined functions, You Can't Do Thatâ„¢.
There may be a suitable set of user-defined functions if you must do it. But doing this sort of thing within a MySQL database is something zealously to be avoided.
Here is the UDF repository.
https://github.com/mysqludf

Related

I need connection to an Access Database from a mysql stored procedure to update tables i already create in mysql db

The access database is on server in folder. I need to create a stored procedure to connect to the access database and update the table data. It can be truncate then an insert. It is connecting via stored procedure to the access database i cannot figure out. It has to be done via a job on a schedule.
MySQL (the Sun- then Oracle- owned product) lacks the plumbing to connect to external tables unless they're on other MySQL servers. That is, it only has a FEDERATED storage engine. So, with MySQL you'll have to find some other way to handle your requirement; a MySQL event or other stored code cannot hit your Access tables.
MariaDB, the MySQL fork, has a CONNECT storage engine. It allows the server to hit external tables via ODBC, so you can hit Access with it. MariaDB is almost entirely compatible with MySQL, so maybe you can replace your MySQL server with it. The CONNECT documentation says this, however.
...these table types cannot be ranked as stable. Use them with care in production applications.
To me, that warning means don't do it!. Especially with a busy business-critical application (like a credit department might use) you don't want even a little bit of instability. If you truncate a table and then the reload fails, you'll be able to hear users yelling from the next county.
Your requirement is, I believe, to extract the contents of one (or more) Access tables and import them into a MySQL table. That kind of operation is called extract-transform-load etl. It seems you use SSIS for the purpose. That should work, because SSIS can connect to Access (of course) and to MySQL via the Connector/net or Connector/ODBC drivers.
But, scheduled SSIS packages get run from SQL Server database servers. You didn't say you have one of those at your disposal. If your org does have a production SQL Server instance, you can put your Access - to - MySQL package into it.
Otherwise you will have to figure out a way to run your scheduled etl job without relying on a database job (or event, as they're called in the MySQL world). For that you'll use the Task Scheduler on Windows, or a cronjob on a UNIX-derived OS like Linux or FreeBSD.
I bet you can do this work reliably from a Windows PowerShell script or a Linux shell script.

Executing stored procedure from sql developer vs executing from database server

We are monitoring the performance of a stored procedure for experimental purpose.
This stored procedure read a single table and updates 5 table. While monitoring, I was expecting it to use network traffic. But to my surprise there were no network traffic.
The SQL developer is on my local machine. My assumption is it would use client service to connect to database and run the stored procedure on the database.
Kindly confirm my understanding and provide additional details.
Thanks.
Two things to consider...
You mentioned that SQL Developer is on your local machine. Is the database there too?
SQL Server by default uses port 1433. Are you watching that port?
As commented below, If you're using Oracle, check port 1521.
If you are using Oracle and TNS, check tnsnames.ora file to see if a port is specified there.

call mysql stored procedure through vba

I have created a stored procedure in mysql workbench located on server. I need to call this stored procedure through a vba application located on local machine. I am stuck on it unable to connect to mysql stored procedure. Thanks in advance for responses .
Have you setup a DSN with an ODBC connection yet?
Assuming so - check out simple examples at
It wasn't hard to find this on Google
DAO Examples

godaddy create stored procedure in mysql hosting

I have hosted a website in godaddy with php/mysql/apache. Now I want to create stored procedure in mysql but find that no options in cPanel for me to do. When I just paste the create sql in cPanel SQL window, it said it need super privileges to do that. After google in the website, it said I can remote connect to godaddy mysql and create in my mysql console workbench. But when I setup in the mysql console, it said it cannot connect after test connection. What should I do? What is the correct steps to do that??
Just make sure your stored procedures are labeled as DETERMINISTIC.
This is an example of an allowed stored procedure form Godaddy help pages :
DELIMITER $$
DROP PROCEDURE IF EXISTS `spGetSouls`$$
CREATE PROCEDURE `spGetSouls`()
DETERMINISTIC
BEGIN
SELECT * FROM soul;
END$$
DELIMITER ;
CALL spGetSouls();
There might be something wrong with your account- I was able to create stored procedures on mine. In cPanel, I picked phpMyAdmin and selected on of my databases. There'll be a "Routines" tab showing. I created a new routine (type of procedure) to create a stored procedure and it saved successfully. If this isn't working for you, I'd suggest opening a support ticket
Using MySQL work bench would be the best option. You should be able to connect with the same hostname/IP that shows in cPanel. Try opening a command prompt and running the following:
telnet <cpanel_account_ip> 3306
That should be working (just tested and mine works great). If it's not, you might have a firewall rule blocking it. When you use Workbench, make sure you connect with the database user defined under the MySQL databases. You may need to associate that user with the database (which you can also do from the MySQL databases page in cPanel).
Let us know how it works out!

mysql server: stored procedures - when do i create the stored procedures?

I found tutorials on creating a stored procedures on the net, I just don't understand when exactly do I need to execute the creation of the stored procedure.
do the stored procedures creation should be executed each time i restart my MySQL server ?
do I need to execute the stored procedures creation sql each time I start my application?
Stored procedures are persisted to the database, ie they will be there even after a restart of the database server. You create them once and then you run them as often as you need. Of course you may want to change them sometimes using an alter statement.