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 ?
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.

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

your direction of connection is not clear.

Is the MySQL remote or local?

Using 3306 is not advisable if local MySQL is running.
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
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
Active Protection takes the fight to cryptojacking

While there were several headline-grabbing ransomware attacks during in 2017, another big threat started appearing at the same time that didn’t get the same coverage – illicit cryptomining.

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.
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.
AXISHKAuthor Commented:
Any sample for giving me some idea how to make it work ? Tks
if you have perl on your system,
The below module is often installed and the example includes how to connect and ...
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
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.

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.