Installing mysql-python on Centos

前端 未结 5 1600
逝去的感伤
逝去的感伤 2020-12-03 01:45

I\'m trying to get the MySQL-python lib installed on centos 5.5. I ran

sudo yum install MySQL-python

but then when I tried:



        
5条回答
  •  情话喂你
    2020-12-03 02:31

    Step 1 - Install package

    # yum install MySQL-python
    Loaded plugins: auto-update-debuginfo, langpacks, presto, refresh-packagekit
    Setting up Install Process
    Resolving Dependencies
    --> Running transaction check
    ---> Package MySQL-python.i686 0:1.2.3-3.fc15 will be installed
    --> Finished Dependency Resolution
    
    Dependencies Resolved
    
    ================================================================================
     Package              Arch         Version                 Repository      Size
    ================================================================================
    Installing:
     MySQL-python         i686         1.2.3-3.fc15            fedora          78 k
    
    Transaction Summary
    ================================================================================
    Install       1 Package(s)
    
    Total download size: 78 k
    Installed size: 220 k
    Is this ok [y/N]: y
    Downloading Packages:
    Setting up and reading Presto delta metadata
    Processing delta metadata
    Package(s) data still to download: 78 k
    MySQL-python-1.2.3-3.fc15.i686.rpm                       |  78 kB     00:00     
    Running rpm_check_debug
    Running Transaction Test
    Transaction Test Succeeded
    Running Transaction
      Installing : MySQL-python-1.2.3-3.fc15.i686                               1/1 
    
    Installed:
      MySQL-python.i686 0:1.2.3-3.fc15                                              
    
    Complete!
    

    Step 2 - Test working

    import MySQLdb
    db = MySQLdb.connect("localhost","myusername","mypassword","mydb" )
    cursor = db.cursor()
    cursor.execute("SELECT VERSION()")
    data = cursor.fetchone()    
    print "Database version : %s " % data    
    db.close()
    

    Ouput:

    Database version : 5.5.20 
    

提交回复
热议问题