Linux study Notes-install and uninstall mysql in ubuntu

Source: Internet
Author: User
Linux Study Notes & mdash; install and uninstall mysql in ubuntu Abstract: This section describes how to install and uninstall mysql in ubuntu.

Abstract: this article mainly introduces how to install and uninstall mysql, how to install mysql using apt commands, and how to solve the encoding problem. it will be solved in the following notes. the final purpose is to allow installation. mysql can be used normally and can be operated remotely.

I. INTRODUCTION 1. environment introduction:

My Linux system is ubuntu12.0.4. Mysql is automatically installed using apt-get.

Because it has been installed before, we should first solve how to completely uninstall and clean mysql, and then install it. For installation steps, go to the following.

The account used is the root account. if it is a normal account, you can add sudo before the corresponding command to obtain the root execution permission.

2. Related Command Introduction: 2.1 apt-get

Apt -- Advancedpackage tool;

The high-level packaging tool is the software package manager of Debian and its derivative releases (such as ubuntu. APT can automatically download, configure, and install software packages in binary or source code format, which simplifies the process of managing software on Unix systems. apt-get commands generally require root permission for execution, therefore, the sudo command is generally followed.

The detailed usage of this command will be added in the supplement section.

2.2 dpkg

Dpkg -- Debian package manager

Dpkg is a tool to install, build, removeand manage Debian packages.

The following is a detailed description.

II. uninstall 2.1 manually uninstall

Two mysql related files need to be manually deleted, one is/var/lib/mysql, and the other is/etc/mysql. After deletion, reinstall the database. if the/var/lib/mysql file is not deleted, the instance created in the previous database will be retained. this is generally not what we want and can be deleted as needed.

                apt-get -y autoremove --purgemysql-server-5.5                apt-get -y remove mysql-server                apt-get -y autoremove mysql-server                apt-get -y remove mysql-common                apt-get -y autoremove mysql-client-core-5.5                dpkg -l |grep ^rc|awk '{print $2}' | xargsdpkg -P                cd /etc                rm -rf mysql/                cd /var/lib                rm -rf mysql/                cd ~
2.2 Automatic uninstall

You can set the preceding command into a shell -- mysql_uninstall.sh:

                #!/bin/bash                #Program                #      The shell of mysql uninstall .                #2014/04/10     andyChen        First release.                apt-get -y autoremove --purgemysql-server-5.5                apt-get -y remove mysql-server                apt-get -y autoremove mysql-server                apt-get -y remove mysql-common                apt-get -y autoremove mysql-client-core-5.5                dpkg -l |grep ^rc|awk '{print $2}' | xargsdpkg -P                cd /etc                rm -rf mysql/                cd /var/lib                rm -rf mysql/                cd ~
III. installation 3.1 Manual installation

The following two commands are used to install the SDK, the account is root, and a dialog box is displayed, prompting you to enter the password,

                apt-get-y install mysql-server                apt-get -y install mysql-client
3.2 Automatic installation

Combine the command set into a shell script, and use debconf-set-selections to automatically set the password,

#! /Bin/bash # Program: # The shell of mysql autoinstall shell. #2014/04/10 andyChen First release export MYSQL_PASS = password cat <
 
  
3.3 Change database password
  

Run the following command and enter the password. the password I set is password. do not forget to flush privileges after execution!

                mysql–uroot –p                usemysql                updateuser set password=password('password') where user = 'root';                flushprivileges; 
4. add 4.1 apt-get.

Command format

Apt-get [option] command apt-get [option] install | remove pkg1 [pkg2...]

Apt-get [option] sourcepkg1 [pkg2...]

Command:

Update-obtain the package list again

Upgrade-update

Install-install a new software package

Remove-remove a software package

Autoremove-automatically remove all unused software packages

Purge-remove software packages and configuration files

Source-Download source code file

Build-dep-configure the compilation dependency for the source package

Dist-upgrade-release version upgrade

Dselect-upgrade-update according to dselect's selection

Clean-clear the downloaded archive file

Autoclean-clear old downloaded archive files

Check-check whether any damaged dependency exists

Command parameters:

-H.

-Q output to log-no progress indication

-Qq does not output information, except for errors

-D. download only-do not install or decompress the archive file

-S is not actually installed. Simulate execution command

-Y: if Yes is selected for all queries, no prompt is displayed.

-F try to fix system dependency corruption

-M. If the archive cannot be located, try to continue.

-U displays the update package list at the same time.

-B. obtain the source code package and compile it.-V displays the detailed version number.

-C =? Read this configuration file

-O =? Set custom configuration options, such as-odir: cache =/tmp

Command application:

Apt-cache search packagename search package

Apt-cache show packagename obtains the package information, such as description, size, and version.

Apt-get install packagename installation package

Apt-get install packagename -- reinstall re-installation package

Apt-get-f install "-f =-fix-missing"

Apt-get remove packagename Delete Package

Apt-get remove packagename -- purge: Delete a package, including deleting a configuration file.

Apt-get update source

Apt-get upgrade: update installed packages

Apt-get dist-upgrade system

Apt-get dselect-upgrade using dselect

Apt-cache depends packagename for dependency usage

Apt-cache rdepends packagename is used to check which packages are dependent on this package.

Apt-get build-dep packagename install the relevant compiling environment

Apt-get source packagename download the source code of the package

Apt-get clean clear useless packages

Apt-get autoclean clear useless packages

Apt-get check to check for any corrupted dependencies

4.2 dpkg

Command format:

Dpkg [option] <命令>

Command parameters:

-I package. deb installation package

-R package: Delete a package

-P package: Delete a package (including configuration files)

-L package: list the files associated with the package

-L package: displays the version of the package.

-Unpackpackage. deb unbind the content of the deb package

-S keyword: Search the package content

-L list the packages currently installed

-C package. deb: list the deb package content

-Configurepackage configuration package

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.