Friday, December 9, 2011

completely remove and clean MySQL installation ubuntu

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

apt-get autoremove
apt-get autoclean


see if anything depends on the installed packages
apt-cache rdepends mysql-server
apt-cache rdepends mysql-client


delete preferences(the next find command will delete everything):
rm -rf /etc/mysql

check to see if mysql is running:
service mysql status

Want to know service status;
service packagename status

-----------------installation of mysql--------------

First, install the MySQL server and client packages:
sudo apt-get install mysql-server mysql-client
 
When done, you have a MySQL database read to rock 'n roll. However, there's more to do.
You need to set a root password, for starters. MySQL has it's own user accounts, which are not related to the user accounts on your Linux machine. By default, the root account of the MySQL Server is empty. You need to set it. Please replace 'mypassword' with your actual password and myhostname with your actual hostname.

sudo mysqladmin -u root -h localhost password 'mypassword'
sudo mysqladmin -u root -h myhostname password 'mypassword'
 
Now, you probably don't want just the MySQL Server. Most likely you have Apache+PHP already installed, and want MySQL to go with that. Here are some libraries you need to install to make MySQL available to PHP:

sudo apt-get install php5-mysql

You can now access your MySQL server like this:

mysql -u root -p
Happy coding...;-)