How can I reset my MySQL password?

To reset your mysqld password just follow these instructions :

Stop the mysql demon process using this command :
sudo /etc/init.d/mysql stop
Start the mysqld demon process using the –skip-grant-tables option with this command
sudo /usr/sbin/mysqld –skip-grant-tables –skip-networking &
Because you are not checking user privs at this point, it’s safest to disable networking. In Dapper, /usr/bin/mysqld… did not work. However, mysqld –skip-grant-tables did.

start the mysql client process using this command
mysql -u root
from the mysql prompt execute this command to be able to change any password
Then reset/update your password
SET PASSWORD FOR root@’localhost’ = PASSWORD(‘password’);
If you have a mysql root account that can connect from everywhere, you should also do:
UPDATE mysql.user SET Password=PASSWORD(‘newpwd’) WHERE User=’root’;
Alternate Method:
USE mysql
UPDATE user SET Password = PASSWORD(‘newpwd’)
WHERE Host = ‘localhost’ AND User = ‘root’;
And if you have a root account that can access from everywhere:
USE mysql
UPDATE user SET Password = PASSWORD(‘newpwd’)
WHERE Host = ‘%’ AND User = ‘root’;
For either method, once have received a message indicating a successful query (one or more rows affected), flush privileges:

Then stop the mysqld process and relaunch it with the classical way:

sudo /etc/init.d/mysql stop
sudo /etc/init.d/mysql start
When you have completed all this steps ,you can easily access to your mysql server with the password you have set in the step before. An easy way to have a full control of your mysql server is phpmyadmin (, software made in php that can give you a web interface that can be very usefull to people that havent got a lot of confidence with bash .To install phpmyadmin on you server you will need to have 4 things:

web server apache
mysql server/mysql client installed
php_mysql support for apache
All packages can be found browsing synaptic.

Another way, purge
I also had some problems with mysql just not accepting my password. I tried the other way as well and it just ended up being difficult. I had not been able to use mysql so it was empty anyway. If this is also your case you may opt for the PURGE way. This removes every file related to mysql. Depending on your installation the packages might be diffrent, mysql-server in 6.10 is called mysql-server-5.0 as an example.


sudo apt-get –purge remove mysql-server mysql-common mysql-client

sudo apt-get install mysql-server mysql-common mysql-client
In the next step be sure to chance the your-new-password with the password you want!

mysqladmin -u root password your-new-password
sudo /etc/init.d/mysql restart

mysql -u root -p
You should now be logged in as root. Make sure to notedown your password! Thanks to Illuvator for posting this method in the ubuntu forum.


How to restart tomcat

if you are using extracted tomcat then, and are two script located in TOMCAT/bin/ to start and shutdown tomcat, You could use that

if tomcat is installed then

/etc/init.d/tomcat5.5 start
/etc/init.d/tomcat5.5 stop
/etc/init.d/tomcat5.5 restart

How to install MySQL in Ubuntu

To install MySQL, run the following command from a terminal prompt:

sudo apt-get install mysql-server
As of Ubuntu 12.04, MySQL 5.5 is installed by default. Whilst this is 100% compatible with MySQL 5.1 should you need to install 5.1 (for example to be a slave to other MySQL 5.1 servers) you can install the mysql-server-5.1 package instead.

During the installation process you will be prompted to enter a password for the MySQL root user.

Once the installation is complete, the MySQL server should be started automatically. You can run the following command from a terminal prompt to check whether the MySQL server is running:

sudo netstat -tap | grep mysql
When you run this command, you should see the following line or something similar:

tcp 0 0 localhost:mysql *:* LISTEN 2556/mysqld
If the server is not running correctly, you can type the following command to start it:

sudo service mysql restart
You can edit the /etc/mysql/my.cnf file to configure the basic settings — log file, port number, etc. For example, to configure MySQL to listen for connections from network hosts, change the bind-address directive to the server’s IP address:

bind-address =
Replace with the appropriate address.

After making a change to /etc/mysql/my.cnf the MySQL daemon will need to be restarted:

sudo service mysql restart
If you would like to change the MySQL root password, in a terminal enter:

sudo dpkg-reconfigure mysql-server-5.5
The MySQL daemon will be stopped, and you will be prompted to enter a new password.

Database Engines
Whilst the default configuration of MySQL provided by the Ubuntu packages is perfectly functional and performs well there are things you may wish to consider before you proceed.

MySQL is designed to allow data to be stored in different ways. These methods are referred to as either database or storage engines. There are two main engines that you’ll be interested in: InnoDB and MyISAM. Storage engines are transparent to the end user. MySQL will handle things differently under the surface, but regardless of which storage engine is in use, you will interact with the database in the same way.

Each engine has its own advantages and disadvantages.

While it is possible, and may be advantageous to mix and match database engines on a table level, doing so reduces the effectiveness of the performance tuning you can do as you’ll be splitting the resources between two engines instead of dedicating them to one.

MyISAM is the older of the two. It can be faster than InnoDB under certain circumstances and favours a read only workload. Some web applications have been tuned around MyISAM (though that’s not to imply that they will slow under InnoDB). MyISAM also supports the FULLTEXT data type, which allows very fast searches of large quantities of text data. However MyISAM is only capable of locking an entire table for writing. This means only one process can update a table at a time. As any application that uses the table scales this may prove to be a hindrance. It also lacks journaling, which makes it harder for data to be recovered after a crash. The following link provides some points for consideration about using MyISAM on a production database.

InnoDB is a more modern database engine, designed to be ACID compliant which guarantees database transactions are processed reliably. Write locking can occur on a row level basis within a table. That means multiple updates can occur on a single table simultaneously. Data caching is also handled in memory within the database engine, allowing caching on a more efficient row level basis rather than file block. To meet ACID compliance all transactions are journaled independently of the main tables. This allows for much more reliable data recovery as data consistency can be checked.

As of MySQL 5.5 InnoDB is the default engine, and is highly recommended over MyISAM unless you have specific need for features unique to the engine.

Advanced configuration
Creating a tuned my.cnf file

There are a number of parameters that can be adjusted within MySQL’s configuration file that will allow you to improve the performance of the server over time. For initial set-up you may find Percona’s my.cnf generating tool useful. This tool will help generate a my.cnf file that will be much more optimised for your specific server capabilities and your requirements.

Do not replace your existing my.cnf file with Percona’s one if you have already loaded data into the database. Some of the changes that will be in the file will be incompatible as they alter how data is stored on the hard disk and you’ll be unable to start MySQL. If you do wish to use it and you have existing data, you will need to carry out a mysqldump and reload:

mysqldump –all-databases –all-routines -u root -p > ~/fulldump.sql
This will then prompt you for the root password before creating a copy of the data. It is advisable to make sure there are no other users or processes using the database whilst this takes place. Depending on how much data you’ve got in your database, this may take a while. You won’t see anything on the screen during this process.
Once the dump has been completed, shut down MySQL:

sudo service mysql stop
Now backup the original my.cnf file and replace with the new one:
sudo cp /etc/my.cnf /etc/my.cnf.backup
sudo cp /path/to/new/my.cnf /etc/my.cnf
Then delete and re-initialise the database space and make sure ownership is correct before restarting MySQL:
sudo rm -rf /var/lib/mysql/*
sudo mysql_install_db
sudo chown -R mysql: /var/lib/mysql
sudo service start mysql
Finally all that’s left is to re-import your data. To give us an idea of how far the import process has got you may find the ‘Pipe Viewer’ utility, pv, useful. The following shows how to install and use pv for this case, but if you’d rather not use it just replace pv with cat in the following command. Ignore any ETA times produced by pv, they’re based on the average time taken to handle each row of the file, but the speed of inserting can vary wildly from row to row with mysqldumps:
sudo apt-get install pv
pv ~/fulldump.sql | mysql
Once that is complete all is good to go!
This is not necessary for all my.cnf changes. Most of the variables you may wish to change to improve performance are adjustable even whilst the server is running. As with anything, make sure to have a good backup copy of config files and data before making changes.

MySQL Tuner

MySQL Tuner is a useful tool that will connect to a running MySQL instance and offer suggestions for how it can be best configured for your workload. The longer the server has been running for, the better the advice mysqltuner can provide. In a production environment, consider waiting for at least 24 hours before running the tool. You can get install mysqltuner from the Ubuntu repositories:

sudo apt-get install mysqltuner
Then once its been installed, run it:
and wait for its final report. The top section provides general information about the database server, and the bottom section provides tuning suggestions to alter in your my.cnf. Most of these can be altered live on the server without restarting, look through the official MySQL documentation (link in Resources section) for the relevant variables to change in production. The following is part of an example report from a production database which shows there may be some benefit from increasing the amount of query cache:
——– Recommendations —————————————————–
General recommendations:
Run OPTIMIZE TABLE to defragment tables for better performance
Increase table_cache gradually to avoid file descriptor limits
Variables to adjust:
key_buffer_size (> 1.4G)
query_cache_size (> 32M)
table_cache (> 64)
innodb_buffer_pool_size (>= 22G)
One final comment on tuning databases: Whilst we can broadly say that certain settings are the best, performance can vary from application to application. For example, what works best for WordPress might not be the best for Drupal, Joomla or proprietary applications. Performance is dependent on the types of queries, use of indexes, how efficient the database design is and so on. You may find it useful to spend some time searching for database tuning tips based on what applications you’re using it for. Once you get past a certain point any adjustments you make will only result in minor improvements, and you’ll be better off either improving the application, or looking at scaling up your database environment through either using more powerful hardware or by adding slave servers.

How To Install Apache Tomcat on Ubuntu 12.04

About Apache Tomcat
Apache tomcat is a Java based application server released by the Apache Software Foundation. It is a web server and a servlet container for Java web applications.
Tomcat installation on a virtual private server is relatively easy. Its single required dependency is Java and this tutorial will include a step on how to install that platform.

You do need to have a user with sudo privileges for this tutorial.
Step One—Install Tomcat
The most recent version of Tomcat is 7, and it can be easily downloaded through apt-get or from the Apache Tomcat site.

You can download it through apt-get by typing:
sudo apt-get install tomcat7

To download tomcat from their site, copy the link for the tar.gz package under the “Core” section and begin the download. You will get a link that originates from one of Apache’s many mirrors, making the command look mostly like this (although coming from a different site).

After the download completes, untar the file.
tar xvzf apache-tomcat-7.0.29.tar.gz

Finish up the Tomcat installation on the VPS by moving the files to a convenient directory.
sudo mv apache-tomcat-7.0.29 ~/path/to/tomcat

Step Two—Install Java
We installed the entire Apache Tomcat server on our virtual server in the previous step. Before we can use it, however, we do need to have Java installed on the VPS as well. If you currently do not have java, you can download it quite easily with apt-get.
sudo apt-get install default-jdk

Once you have Tomcat and Java installed on the virtual private server, all that remains is to start them.
Step Three—Configure .bashrc
In order to start Tomcat, we need to add it as an environment variable in the /.bashrc file.
sudo nano ~/.bashrc

You can add this information to the end of the file:
export JAVA_HOME=/usr/lib/jvm/default-java
export CATALINA_HOME=~/path/to/tomcat

Save and exit out of .bashrc. You can make the changes effective by restarting the bashrc file.
. ~/.bashrc

Tomcat is now installed and configured on our virtual servers. However, it is not yet activated. The final step is to activate Tomcat by running its startup script:

Once that runs, Tomcat is up and ready on port 8080.

You can visually verify that Tomcat is working by accessing your server page at your_IP_address:8080.

It should look like this

MySQL Database Backup Using Mysqldump Command.

1. Getting backup of a MySQL database using mysqldump.
Use following command line for taking backup of your MySQL database using mysqldump utility.
mysqldump –-user [user name] –-password=[password] [database name] > [dump file]


mysqldump –u[user name] –p[password] [database name] > [dump file]
mysqldump –-user root –-password=myrootpassword db_test > db_test.sql


mysqldump –uroot –pmyrootpassword db_test > db_test.sql
2. Backup multiple databases in MySQL.
mysqldump –u[user name] –p[password] [database name 1] [database name 2] .. > [dump file]
mysqldump –-user root –-password=myrootpassword db_test db_second db_third > db_test.sql
3. Backup all databases in MySQL.
shell> mysqldump –u[user name] –p[password] –all-databases > [dump file]
4. Backup a specific table in MySQL.
shell> mysqldump –user [username] –password=[password] [database name] [table name] \
> /tmp/sugarcrm_accounts_contacts.sql
shell> mysqldump –user root –password=myrootpassword db_test customers \
> db_test_customers.sql
5. Restoring MySQL database.
The mysqldump utility is used only to take the MySQL dump. To restore the database from the dump file that you created in previous step, use mysql command.
shell> mysql –u [username] –password=[password] [database name] mysql –user root –password=myrootpassword new_db < db_test.sql

Install the Twilio Python Helper Library

The twilio-python helper library lets you write Python code to make HTTP requests to the Twilio API.

The easiest way to install twilio-python is from PyPi using pip, a package manager for Python. Simply run this in the terminal:

1. pip install twilio

If you get a pip: command not found error, you can also use easy_install. Run this in your terminal:

1. easy_install twilio

Or, you can download the source code (ZIP) for twilio-python, and then install the library by running:

1. python install

in the folder containing the twilio-python library.

“Permission Denied”

If the command line gives you a big long error message that says Permission Denied in the middle of it, try running the above commands with sudo, ex. sudo pip install twilio.

Linux: Install pip Client To Install Python Packages

The pip command is a tool for installing and managing Python packages, such as those found in the Python Package Index. It’s a replacement for easy_install. pip is very useful for web development as well as for sys-admins who manages cloud computing based resources created Openstack, Rackspace, AWS, Google and other cloud computing service providers. The pip command can be installed in two different methods:
Method #1: pip for all users with root privileges required. It is recommended that you use package manager to install the pip.
Method #2: pip for a single user with no root privileges required. It is recommended that you use virtualenv script, which create isolated Python environments in your $HOME directory.
Warning examples may crash your computerWARNING! Only use any one of the following method to install pip. Do not install pip using both methods.
Method #1: Install pip for all users

The pip command is not installed by default. You need to install it as per your distro.

RHEL / CentOS / Fedora Linux installation

First, turn on EPEL repo for RHEL / CentOS Linux. Next, type the following yum command under RHEL / CentOS / Fedora Linux to install python-pip package:
# yum -y install python-pip

Sample outputs:

Loaded plugins: product-id, refresh-packagekit, rhnplugin, security,
: subscription-manager
Updating certificate-based repositories.
Unable to read consumer identity
Setting up Install Process
Resolving Dependencies
–> Running transaction check
—> Package python-pip.noarch 0:0.8-1.el6 will be installed
–> Processing Dependency: python-setuptools for package: python-pip-0.8-1.el6.noarch
–> Running transaction check
—> Package python-setuptools.noarch 0:0.6.10-3.el6 will be installed
–> Finished Dependency Resolution

Dependencies Resolved

Package Arch Version Repository Size
python-pip noarch 0.8-1.el6 epel 178 k
Installing for dependencies:
python-setuptools noarch 0.6.10-3.el6 rhel-x86_64-workstation-6 336 k

Transaction Summary
Install 2 Package(s)

Total download size: 513 k
Installed size: 764 k
Is this ok [y/N]: y
Downloading Packages:
(1/2): python-pip-0.8-1.el6.noarch.rpm | 178 kB 00:01
(2/2): python-setuptools-0.6.10-3.el6.noarch.rpm | 336 kB 00:00
Total 63 kB/s | 513 kB 00:08
warning: rpmts_HdrFromFdno: Header V3 RSA/SHA256 Signature, key ID 0608b895: NOKEY
Retrieving key from file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-6
Importing GPG key 0x0608B895:
Userid : EPEL (6)
Package: epel-release-6-7.noarch (installed)
From : /etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-6
Is this ok [y/N]: y
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
Warning: RPMDB altered outside of yum.
Installing : python-setuptools-0.6.10-3.el6.noarch 1/2
Installing : python-pip-0.8-1.el6.noarch 2/2
Installed products updated.
Verifying : python-setuptools-0.6.10-3.el6.noarch 1/2
Verifying : python-pip-0.8-1.el6.noarch 2/2

python-pip.noarch 0:0.8-1.el6

Dependency Installed:
python-setuptools.noarch 0:0.6.10-3.el6


Please note that name of the command is pyton-pip under RHEL and friends. I recommend that you add the following alias to your ~/.bashrc file, enter:

$ echo ‘alias pip=”/usr/bin/pip-python”‘ >> $HOME/.bashrc
$ . $HOME/.bashrc

Debian / Ubuntu Linux installation

Type the following apt-get command to install
# apt-get install python-pip

$ sudo apt-get install python-pip

Sample outputs:

Reading package lists… Done
Building dependency tree
Reading state information… Done
The following NEW packages will be installed:
0 upgraded, 1 newly installed, 0 to remove and 14 not upgraded.
Need to get 67.8 kB of archives.
After this operation, 332 kB of additional disk space will be used.
Get:1 squeeze/main python-pip all 0.7.2-1 [67.8 kB]
Fetched 67.8 kB in 1s (40.4 kB/s)
Selecting previously deselected package python-pip.
(Reading database … 274928 files and directories currently installed.)
Unpacking python-pip (from …/python-pip_0.7.2-1_all.deb) …
Processing triggers for man-db …
Setting up python-pip (0.7.2-1) …
Processing triggers for python-support …
Method #2: Install pip for a single user

This method does not require root access or modify your system Python installation. Type the following command:

curl -O
Sample outputs:

% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 107k 100 107k 0 0 35120 0 0:00:03 0:00:03 –:–:– 49618
Create your own virtual environment called py_virtual:

python py_virtual
Sample outputs:

New python executable in py_virtual/bin/python
Installing setuptools……………………….done.
Installing pip…………………done.
Activate your new virtual environment, run:

. py_virtual/bin/activate
Sample outputs (note prompt changed):

How do I use pip command?

To install new python package type:

pip install packageName
To uninstall python package installed by pip type:

pip uninstall packageName
To search python package type:

pip search packageName
To see a list of all commands type:

pip help
Sample outputs

–version show program’s version number and exit
-h, –help Show help
-v, –verbose Give more output
-q, –quiet Give less output
–log Log file where a complete (maximum verbosity) record will be kept
–proxy Specify a proxy in the form user:passwd@proxy.server:port. Note that the user:password@ is optional and required only if you
are behind an authenticated proxy. If you provide user@proxy.server:port then you will be prompted for a password.
–timeout Set the socket timeout (default 15 seconds)
Default action when a path already exists. Use this option more than one time to specify another action if a certain option is
not available. Choices: (s)witch, (i)gnore, (w)ipe, (b)ackup
Commands available:
bundle: Create pybundles (archives containing multiple packages)
freeze: Output all currently installed packages (exact versions) to stdout
help: Show available commands
install: Install packages
search: Search PyPI
uninstall: Uninstall packages
unzip: Unzip individual packages
zip: Zip individual packages

Search all openstack cloud releated tools:

pip search openstack
Sample outputs:

ftp-cloudfs – FTP interface to Rackspace Cloud Files and OpenStack Swift
vaporize – A clean and consistent library for the Rackspace Cloud / OpenStack
openstack.nose_plugin – openstack style output for nosetests
nova-adminclient – client for administering OpenStack Nova
python-glanceclient – Client library for OpenStack Image API
python-novaclient – Client library for OpenStack Nova API.
python-quantumclient – CLI and python client library for OpenStack Quantum
python-melangeclient – Client library for OpenStack Melange API.
txAWS – Async library for EC2, OpenStack, and Eucalyptus
python-swiftclient – Client Library for OpenStack Object Storage API
python-keystoneclient – Client library for OpenStack Keystone API
django_openstack_auth – A Django authentication backend for use with the OpenStack Keystone Identity backend.
python-cinderclient – Client library for OpenStack Cinder API.
rackspace-auth-openstack – Rackspace Auth Plugin for OpenStack Clients.
openstackocci – OCCI interface for Openstack.
django-openstack – A Django interface for OpenStack.
futuregrid_passwdstack – Password Stack is a simple tool that allows normal users to reset their own password in the OpenStack Dashboard
cloudenvy – Fast provisioning on openstack clouds.
reddwarf – PaaS services for Openstack
python-openstackclient – OpenStack command-line client
reviewday – Report generator for OpenStack code reviews.
horizon – The OpenStack Dashboard.
hpcloud-auth-openstack – HP Cloud Auth Plugin for OpenStack Clients.
To install the OpenStack dashboard package called horizon, enter:

pip install horizon
PyPI – the Python Package Index.
Pip installer documentation and download from the official project site.