Monday, July 21, 2014

How to install and uninstall MySQL in Ubuntu Linux

This post talks about how to install and remove MySQL to and from the Ubuntu Linux system.


Part 1: How to install MySQL to Linux
  1. First, remove the current version of MySQL you're already using. Please follow the steps in Part 2.
  2. Now, to install MySQL, run the following command from a terminal prompt:
    $ sudo apt-get install mysql-server
    $ sudo apt-get install mysql-client
    During the installation process you will be prompted to enter a password for the MySQL root user.
    If there is any error during installation, try
    $ sudo apt-get update
    $ sudo apt-get upgrade
  3. 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
  4. When you run the above command, you should see the following line or something similar:
    tcp        0      0 localhost.localdomain:mysql           *:* LISTEN -
  5. If the server is not running correctly, you can type the following command to start it:
    $ sudo /etc/init.d/mysql restart
    You can edit the /etc/mysql/my.cnf file to configure the basic settings: log file, port number, etc.

Part 2: How to remove MySQL from Linux
To remove mysql completely from your system Just type in terminal:
sudo apt-get remove --purge mysql-server mysql-client mysql-common
sudo apt-get autoremove
sudo apt-get autoclean
(Note: this assumes only mysql-server, mysql-client, and mysql-common are installed)

No comments:

Post a Comment