Home > mysql > Installing mysql-server with python ssh connection

Installing mysql-server with python ssh connection

November 18Hits:2
Advertisement

I'm writing a script in Python, which is connecting to server via ssh, then installing some packages. But there is problem with dialogue box, where i can type in a root password- i don't know how to send data there. Once I tried to do this, my apt(using Debian Lenny) gone crazy.

Here is some info: - Debian Lenny - Using PySSH with easier interface, code looks like this:

clientSSH = SSHClient( self.ip, 'root', self.rootPassword, None ) clientSSH.login() clientSSH.run_command('apt-get install mysql-server mysql-client php5') clientSSH.run_command('Y') #I Don't know how send root passwd here clientSSH.logout() 

Answers

Use apt-get -y

  • see apt-get(1)

And for SSH if you're not: use password-less ssh keys

http://www.debian-administration.org/articles/152

I would suggest trying:

apt-get -y install mysql-server mysql-client php5

The -y switch answers yes to all questions by default.

As far as the root password for MySQL goes, you may have to use a module like Pexpect to send the password, if you find yourself unable to pipe it through PySSH or cannot reliably determine when to send it.

updated answer:

I researched this a little and it seems you have a couple choices, both pretty involved on your part:

  1. Use Pexpect.
  2. Build a custom .deb that removes the password prompt from the "postinst" script
  3. Use apt-get and dpkg to unpack but not configure MySQL.

Option 1: Rewrite your script to use Pexpect (this should be able to handle ncurses)

Option 2:

# get the original .deb:
apt-get -y --download-only -q install mysql-server
# need a tempdir for this
mkdir ~/tmp;cd ~/tmp
cp /var/cache/apt/mysql-version.deb .
ar -x mysql-version.deb
mkdir DEBIAN
tar xf control.tar.gz -C DEBIAN
vim DEBIAN/postinst
# edit the lines about prompting for rootpw in here and replace $rootpw with what you want,
# or however you choose to accomplish this
tar xf data.tar.gz -C .
dpkg-deb -b . mysql-server-version-noprompt.deb

And there's your new .deb. I haven't tested it, so YMMV.

Option 3:

# Skip postinst entirely
apt-get -q -y --download-only mysql-server
dpkg --unpack /var/cache/apt/mysql-server-version.deb
# instead of dpkg you can use dpkg-deb:
dpkg-deb -X /var/cache/apt/mysql-server-version.deb /

This will skip the postinstall entirely -- have a look at the script to see what it does, then repeat those steps.

Tags:mysql, python, ssh

Related Articles

  • Installing mysql-server with python ssh connectionNovember 18

    I'm writing a script in Python, which is connecting to server via ssh, then installing some packages. But there is problem with dialogue box, where i can type in a root password- i don't know how to send data there. Once I tried to do this, my apt(us

  • Installing MySQL server 4.1 on Ubuntu 11.04August 7

    how do I need to install mySQL server 4.1 on Ubuntu 11.04 server for a legacy app to run (it breaks on mySQL 5). sudo apt-get mysql-server-4.1 doesn't work - "package is missing, obsoleted or available from another source". Background: I'm tryin

  • How to install MySQL Server so it doesn't "go away" after reboot?January 28

    All Good: Mysql server installed just fine by using the following command: sudo apt-get install mysql-server During installation I was prompted to choose a root password. After install I was able to log in to mysql monitor using this command: mysql -

  • yum install mysql-server.x86_64 - Transaction Check ErrorsFebruary 16

    I think yum is having problems installing MySQL 5.1 because there is already a pre-existing MySQL 5.5 installation. I wanted to cleanly remove MySQL 5.5 (I had problems with 5.5 with PHP and Python). I removed every folder and file associated with My

  • unable to install mysql server on ubuntu

    unable to install mysql server on ubuntu June 1

    the error I encountered while updating in ubuntu 11.10. since I found that ubuntu 11.10 supports much better than 12.04 for matlab, I have rebooted my OS to ubuntu 11.10. And even here, I face same problem. I feel this must be a trouble from oneiric

  • Issues installing MySQL server on Ubuntu 13.04October 1

    I'm currently trying to install a MySQL server on my Ubuntu 13.04 machine. The problem is, when I try to install it, I get error messages indicating that not all packages could be downloaded. When I run sudo apt-get install mysql-server, and after ha

  • After installing mysql-server, and doing $mysql, mysql won't start. Mysqld.sock missingJune 16

    First, I installed mysql-server Next, I did $mysql I was going to add a database and edit some stuff. But I got this error: ERROR 2002 (HYOOO) : Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2) How do I fix this? T

  • Cannot install mysql-server-5.5/the following packages have unmet dependiciesJune 30

    I'm a newbie here so please bear with me. I'm using ubuntu 14.04. I tried entering mysql with the following command: mysql -u root -p and I got the following message: The program mysql can be found on the following packages: * mysql-client-core-5.5 *

  • Installing mysql-server gives 504 Gateway Time-outSeptember 1

    So I have this site im coding on that requires a database and is based on PHP. So for this site i installed phpmyadmin that also installed mysql-server. Before I installed phpmyadmin I didn't get a 504 message when i tried accessing it but after the

  • when i am running `service mysql status` it is reporting unrecognized service. should i install mysql server as well? December 17

    i have installed MYSQL for Python with the below command. sudo apt-get install python-mysqldb but when i am running service mysql status it is reporting unrecognized service. should i install mysql server as well? i want to run mysql. so that i can i

  • Why can't I successfully install mysql server?January 20

    It's very easy. All I want to do is this: aptitude remove mysql-server mysql-server-5.0 --purge aptitude install mysql-server But when I try to run that I get this error: [email protected]:/etc# aptitude install mysql-server Reading package lists... Done Buil

  • sudo apt-get install mysql-server failsFebruary 20

    I'm coming from a fresh install of Ubuntu server 9.10 and trying to install mysql-server by using 'sudo apt-get mysql-server' I get the following errors: [email protected]:~$ sudo apt-get install mysql-server [sudo] password for dan: Reading package lists... D

  • Can someone help me install MYSQL server pelase? This is bugging meMay 3

    $ sudo aptitude install mysql-server Reading package lists... Done Building dependency tree Reading state information... Done Reading extended state information Initializing package states... Done The following NEW packages will be installed: libhtml

  • installing mysql-server on ubuntu 10.04March 16

    I've had this same issue EVERY time I try: Selecting previously deselected package mysql-server-core-5.1. (Reading database ... 242369 files and directories currently installed.) Unpacking mysql-server-core-5.1 (from .../mysql-server-core-5.1_5.1.41-

  • Unable to install mysql-server in UbuntuApril 1

    I am unable to install mysql-server on my ubuntu 9.10 server machine. When using apt-get install mysql-server the output is : # apt-get install mysql-server Reading package lists... Done Building dependency tree Reading state information... Done mysq

  • Install mysql-server and set password from the command line?October 18

    I am installing MySQL via the command line: sudo apt-get install mysql-server. During the installation process, it prompts me for a root password. How can I specify the MySQL password without having to wait for the screen to pop up and ask me the pas

  • Error while installing mysql-server-5.1December 11

    I need to install mysql-server-5.1 on ubuntu 11.10. While installing with apt-get I am getting dpkg: error processing mysql-server-5.1 (--configure): subprocess installed post-installation script returned error exit status 1 I have tried following th

  • Errors when installing Mysql Server 5.1April 27

    I'm trying to install mysql server,and I'm getting the following error. sudo apt-get install mysql-server-5.1 Reading package lists... Done Building dependency tree Reading state information... Done Suggested packages: tinyca mailx The following NEW

  • Cannot install mysql-server (5.5.22) on clean ubuntu 12.04 LTS serverMay 2

    I have a clean minimal install of Ubuntu 12.04 LTS server 64-bit (just a root user and nothing alse installed). I tried to install the mysql-server with the following command: apt-get install mysql-server The installation aborts with the following er

  • Installing mysql-server on 10.04LTS gives "404 Not Found" errorJuly 2

    Hi I am trying to install mysql on Ubuntu 10.04LTS (Lucid Lynx) and I am getting this error. Is this a server side issue - is the server up? I am running this from the command line on a remote server... sudo apt-get install mysql-server Reading packa

Copyright (C) 2017 ceus-now.com, All Rights Reserved. webmaster#ceus-now.com 14 q. 0.895 s.