Powered By Blogger

Sunday, 13 May 2018

Error loading MySQLdb module: No module named 'MySQLdb' while using mysql with python 3

MySQL with Django

To configure Django to access a MySQL database on Python, you need to do this in your settings file:
DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.mysql',
        'NAME': '<your_username>$<your_database_name>',
        'USER': '<your_username>',
        'PASSWORD': '<your_mysql_password>',
        'HOST': '<your_mysql_hostname>',
    }
}

But on python 3 you will get following error.

Error loading MySQLdb module: No module named MySQLdb.


For Python 3, you have to install "MySQL-for-Python-3":

MySQL-for-Python-3   can be  installed from below repository.
pip3 install --user https://github.com/davispuh/MySQL-for-Python-3/archive/1.0.tar.gz

Thursday, 3 April 2014

Openstack-Keystone failing to start

If openstack-Keystone is not starting:
for eg:
 [root@* keystone]# service openstack-keystone restart
Stopping keystone:                                         [FAILED]
Starting keystone:                                         [  OK  ]
[root@* keystone]# service openstack-keystone restart
Stopping keystone:                                         [FAILED]
Starting keystone:                                         [  OK  ]

Try running keystone manually instead of as a service:
$ sudo -u keystone bash
$ HOME=/var/lib/keystone keystone-all --debug

PHP-FPM Listen On Unix Socket-Ubuntu 12.04

 




  
      In the default configuration  PHP FPM is set to listen on TCP port 9000 on address 127.0.0.1.
This can be changed in /etc/php5/fpm/pool.d/www.conf

Edit the line " listen = 127.0.0.1:9000" and change it to something like  
          listen = /var/run/php5-fpm.sock.
 *you can choose different location if required



Make sure that file php5-fpm.sock is created automatically in
"/var/run ".


Dont create this file manually.


Edit Nginx configs to tell it to pass requests through the unix socket rather than TCP.


For that create a file at /etc/nginx/conf.d/ named php5-fpm.conf:
upstream php5-fpm-sock {
    server unix:/var/run/php5-fpm.sock;
}
 
After doing so, restart PHP FPM:

 sudo /etc/init.d/php5-fpm restart
 

Friday, 28 March 2014

Installation and Configuration of MySQL Cluster NDB 7.2:
MYSQL-CLUSTER is a distributed database system with data nodes storing data and several application nodes for query execution. It is managed by special management nodes. Clients are not able to connect directly to the data nodes to fetch data, all commands must be run and executed over the application nodes.
    MySQL Cluster has one or more of several major componentsA simpler example is to have 2 data nodes1 sql node and 1 management node. This is the most minimal setup.
Physical setup:
Node Details:
  MYSQL-MGMT-Node    
  MYSQL-SQL-Node         
  MYSQL-DataNode1        
  MYSQL-DataNode2     

Download   cluster-server package to all four nodes..

Mysql cluster-server package download URL::


Mysql cluster-client package download:


Installation:

Data nodes:

rpm -Uhv <server-package.rpm>

SQL nodes:
rpm -Uhv <server-package.rpm>
rpm -Uhv <client-package.rpm>

Management nodes:
rpm -Uhv <server-package.rpm>

Configuration:

For  four-node Cluster, it is necessary to write four configuration files, one per node

  •   Each data node or SQL node requires a my.cnf file that provides two pieces of information: a connection string that tells the node where to find the management node, and a line telling the MySQL server on this host (the machine hosting the data node) to enable the NDBCLUSTER storage engine.

·         The management node needs a config.ini file telling it how many replicas to maintain, how much memory to allocate for data and indexes on each data node, where to find the data nodes, where to save data to disk on each data node, and where to find any SQL nodes.


Configuring the data nodes and SQL nodes:
vi /etc/my.cnf

Modify  my.cnf like this:
[mysqld]
# Options for mysqld process:
ndbcluster                      # run NDB storage engine
 
[mysql_cluster]
# Options for MySQL Cluster processes:
ndb-connectstring=<mgmt server IP>  # location of management server

<Do this for the machines hosting data node and the SQL node.>
Configuring the management node:

shell> mkdir /var/lib/mysql-cluster
shell> cd /var/lib/mysql-cluster
shell> vi config.ini
Modify file like this:
[ndbd default]
NoOfReplicas=2    
DataMemory=80M    
IndexMemory=18M   
 
[tcp default]
portnumber=2202   
 
[ndb_mgmd]
hostname=<Mgmt nodeIP>          
datadir=/var/lib/mysql-cluster  
 
[ndbd]
hostname=<datanode IP>
datadir=/usr/local/mysql/data   
 
[ndbd]
hostname=<datanode IP>                  
datadir=/usr/local/mysql/data   
 
[mysqld]
hostname=<sqlnode IP>         

Startup of MySQL Cluster:


The management node should be started first, followed by the data nodes, and then finally by any SQL nodes:
Commands:
Mgmt Node:
shell> ndb_mgmd -f /var/lib/mysql-cluster/config.ini

Data Node:
shell> ndbd

Sql Node:

 shell> mysqld_safe &

Wednesday, 14 November 2012

All Database Backup and Restore

           To backup all  of your MySQL databases, you’ll need to use  mysqldump which comes  with mysql. If you have MySQL installed, you probably have mysqldump installed already.


To backup all databases use the following command:
 mysqldump -uroot -ppassword --all-databases > BackupDB.sql
 or
mysqldump -uroot -p --all-databases > BackupDB.sql

To restore all database use the following command:

mysql -u root -p < BackupDB.sql

Troubleshooting:

ERROR 1556 (HY000) at line 75485: You can't use locks with log tables.

Solution :

You may need to disable “--lock-tables” option on your dump statement ie –lock-tables=0 . 
mysqldump -uroot -ppassword --all-databases --lock-tables=0 > BackupDB.sql
Explanation:
   when we use “–lock-tables” option, the current table which is being backed up will be operating on “read only” mode to avoid further write operations during the time. The cached querry which containing “write’ operation will be executed later once after the table dump has been done. 

Basic commands for the Linux vi Editor

CommandDescription
iinsert mode, (ESC to exit insert mode) allows text to be entered on the screen
aAppend to right mode
/wordMove to the occurrence of "word"
nLocate the next occurrence
wAdvance to the next word
eAdvance to the next end of a word
bMove to the previous word
3bMove backward 3 words
yyCopy line (then move cursor and use p to paste after current cursor line)
dddelete line
3dddelete 3 lines
DDelete remainder of a line
dwDelete word
xDelete character
oOpen space for new line below the cursor line
OOpen a line above the cursor
CTRL-wMove back a word in append mode
uUndo last
UUndo all changes to current line
.In command mode, repeat the last text changing the command on the current line
:w newfilenamesave the file to newfilename from the command mode
:wqsave and quit
:q!quit without saving
rreplace then typa a character ot be replaced with r then return to break up a line
Jjoin 2 lines
ssubstitute (sentence) typed text over a character, ESC when done
cwchange word
cchange part of a line from the cursor to the end of the line
ccsubstitute new text for aline, ESC when done
hmove the cursor back one space
Hmove the cursor to the highest line on the screen
Lmove the cursor to the lowest line on the screen
Mposition the cursor at the midpoint on the screen
Glast line in the file
0 (zero)Move the cursor to the beginning of the line it is on
view filenameOpen a file for viewing only
set numberTurn on line numbers
set nonumberTurn off line numbers
Options
autoindent(ai ctrl-d to move to the left
showmatchmatch brackets and parenthesis
tabstop=4
wrapmargine(wm)when line is wrapped (80-value)
:2 copy 4Place a copy of line 2 after line 4.
:1,4 copy 7(lines 1-4)
:nAccess the next file for editing

Tuesday, 13 November 2012

Change Windows 8 Product Key After Install.

                           Change Windows 8 Product Key After Install.
  1. Launch the Start Menu and type in command prompt or cmd so that it shows up on your start menu search list. Right click on the Command Prompt shortcut and select Run As Administrator.
  2. At the administrator command prompt, type in "slmgr.vbs -ipk <insert your product key here>"

    slmgr.vbs -ipk 00000-00000-00000-00000-00000
  3. To activate windows after changing the key, run "slmgr.vbs -ato"