Dec 092009
 

I write a stored procedure as below but always result nothing/incorect.

DELIMITER //

DROP PROCEDURE IF EXISTS get_domain //

CREATE PROCEDURE get_domain (IN domin VARCHAR(64))
BEGIN
	SELECT * FROM domain_senders WHERE domain LIKE '%domin%';
END//

DELIMITER ;

The procedure itself is successfully created.After looking around with google i’ve found the solution.I need second variable to concat/stash %domin%

Here’s the store procedure, and it work like a charm 🙂

DELIMITER //

DROP PROCEDURE IF EXISTS get_domain //

CREATE PROCEDURE get_domain (IN domin VARCHAR(64))
BEGIN
	SET @vardomain := CONCAT('%',LOWER(TRIM(domin)),'%');
	SELECT * FROM domain_senders WHERE domain LIKE @vardomain;
END//

DELIMITER ;
Sep 202009
 

To encrypt a connection between a mysql client and a mysql server, run two instances of stunnel, one on client site and other on MySQL remote site

Here’s steps how to do it

# wget http://www.stunnel.org/download/stunnel/src/stunnel-4.27.tar.gz
# rpmbuild -ta stunnel-4.27.tar.gz
# rpm -ivh /usr/src/redhat/RPMS/stunnel-4.27-1.i386.rpm

Create stunnel.pem cert on server site

# openssl genrsa -out privkey.pem 2048
# openssl req -new -x509 -key privkey.pem -out cacert.pem -days 1095
# cat privkey.pem cacert.pem >> /etc/stunnel/stunnel.pem

Set the proper permissions on the resulting private key:

# chmod 0400 /etc/stunnel/stunnel.pem

Set the proper ownership of the stunnel chroot dir

# chown nobody:nobody /var/run/stunnel

Continue reading »