create ssl tunnel on mysql server

I have create a ssh tunnel to the SQL server

ssh -L 3306:localhost:3306 sciadm@mysql
after inputing the password, i need to issue mysql -usciadm -pxxxx to connect to the server.

1. How to prevent user from asking for password ?
2. how to put every thing in a script such that when user run the script, it will do all the connection at the same time ?
AXISHKAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

arnoldCommented:
I have create a ssh tunnel to the SQL server

ssh -L 3306:localhost:3306 sciadm@mysql
after inputing the password, i need to issue

mysql -usciadm -pxxxx -H 127.0.0.1:3306

your direction of connection is not clear.

Is the MySQL remote or local?

Using 3306 is not advisable if local MySQL is running.
0
AXISHKAuthor Commented:
ServerA  --> Server B (MySQL)

On ServerA
ssh -L 3306:localhost:3306 sciadm@mysql

(localhost - ServerA)

MySQL do not install on ServerA. Any advise ? Tks
0
arnoldCommented:
The example provided will work to allow user on serveA to connect to MySQL on servers provided the user is allowed a connection without specifying a database.

mysql -u sciadm -pxxxx --host localhost --port 3306  database_if_needed
0
The Ultimate Tool Kit for Technolgy Solution Provi

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy for valuable how-to assets including sample agreements, checklists, flowcharts, and more!

AXISHKAuthor Commented:
Actually, I want a server (client) to upload some records on a MySQL server. Ideally, i want to simply execute a script such that

1. It will build up the ssh connection
2. it will connect to the MySQL server
3. make file change (update table A set field1 = x, field2=y, field3=z,...

Any idea or example how to archieve this ?

Thanks again.
0
arnoldCommented:
If you are building a script, why not use scripting technology that can connect to the mysql without the need to establish a tunnel
perl/php etc.
0
AXISHKAuthor Commented:
Any sample for giving me some idea how to make it work ? Tks
0
arnoldCommented:
if you have perl on your system,
The below module is often installed and the example includes how to connect and ...
http://search.cpan.org/~capttofu/DBD-mysql-4.031/lib/DBD/mysql.pm
0
AXISHKAuthor Commented:
Do you mean I need to install perl before connecting to the the MySQL in another RedHat ? No need to install php ?

yum -install perl, correct ?
 
There is no way to put the following two line in a script to execute directly on the origins server.. Correct ?
ssh -L 3306:localhost:3306 sciadm@mysqlserver
mysql -usciadm -pxxxx
0
arnoldCommented:
perl should already be installed?

The issue I am having is that I am makeing comments/dsuggestion on partial information that you shared. Once comment/suggestion is made another set of information/requirement comes up.


Starting from the begining. You have two systems ServerA and ServerB. ServerB has mysql database server running.
You want to have data added to the database on serverB(you named serverB mysql)  from serverA.
Provided serverA can connect to serverB's mysql, you do not need to setup a tunnel
on serverA
mysql -h serverb --port 3306 -u sciadm -ppassword databasename
should let you connect if sciadm user is allowed to connect from serverA to databasename.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
MySQL Server

From novice to tech pro — start learning today.