Linux Study Notes-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 commands:
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 <<MYSQL_PRESEED |debconf-set-selections mysql-server-5.5 mysql-server/root_passwordpassword $MYSQL_PASS mysql-server-5.5mysql-server/root_password_again password $MYSQL_PASS mysql-server-5.5 mysql-server/start_on_bootboolean true MYSQL_PRESEED apt-get -y install mysql-server apt-get -y install mysql-client
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;
Iv. Supplement
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>
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
More: Linux Study Notes-start