How to uninstall and install MySQL in Linux
I wrote a blog for the first time, developed it for two years, found something meaningful for myself after work, and shared some experiences in the development process, at the same time, take your own notes. Sometimes you don't have to remember some things for a long time. Well, let's talk about it here. Next we will explain the detailed steps for uninstalling and installing MySQL in Linux, this article describes how to install MySQL using a Binary Package (source code.
1. Uninstall the MySQL database
1. Check the mysql service and disable the service process.
(1) log on to Linux and run the "service mysqld status" or "service mysql status" command to check the MySQL service status. It depends on the file name of the mysql script under the startup initialization directory. Here is mysqld.
(2) If you are running, run the service mysqld stop or service mysql stop command to stop the MySQL service. It depends on the file name of the mysql script under the startup initialization directory. Here I am using mysqld.
2. Find the mysql installation directory and delete it permanently.
(1) execute find/-name mysql to find mysql-related directories.
(2) execute rm-rf 'directory' to delete the searched directory.
3. Delete the mysql configuration file
(1) run the rm-rf/etc/my. cnf command to delete the/etc/my. cnf file.
(2) execute rm-rf/etc/init. d/mysqld command to delete/etc/init. d/All mysql-related files, including mysql files or mysqld files. If a mysql file exists, run rm-rf/etc/init. d/mysql Command
4. Delete mysql users and user groups
(1) run the id mysql command to view MySQL users and user groups.
(2) Run The userdel mysql command to delete MySQL users and user groups.
Mysql has been uninstalled!
Ii. Install the MySQL database
1. Download the mysql installation package
(1) Go to the mysql official website to download the compiled binary installation package, and select the desired version on the download page. (If you have only installed the Windows Installation Package after you enter the download list, you can install the XSkyWalker browser to download it, XSkyWalker: http://www.bkjia.com/softs/192435.html), as shown in:
(2) Pull the page to the bottom, 64-bit system to download Linux-Generic (glibc 2.5) (x86, 64-bit), 32-bit system to download Linux-Generic (glibc 2.5) (x86, 32-bit)
2. Upload and decompress the mysql installation package
Upload the downloaded mysqlinstallation package mysql-5.6.16-linux-glibc2.5-x86_64.tar.gz to the linux host using the ftp tool (I will upload it to the/usr/local/directory here ). Go to the directory where the installation package is located and run the command tar-zxvf mysql-5.6.16-linux-glibc2.5-x86_64.tar.gz to unzip the installation package.
3. Add the mysql user group and users.
Run the following command: groupadd mysql and useradd-r-g mysql.
4. Install the mysql database
(1) execute the command: cd/usr/local to enter the directory for installing MySQL software
(2) execute the command: mv mysql-5.6.16-linux-glibc2.5-x86_64 mysql renamed the unzipped file folder for mysql
(3) run the command cd/usr/local/mysql to enter the mysql installation directory.
(4) execute the command: chown-R mysql: mysql./modify the current directory owner as a mysql user
(5) run the command:./scripts/mysql_install_db -- user = mysql to install the database.
(6) execute the command: chown-R root: root./modify the current directory owner as the root user.
(7) run the command chown-R mysql: mysql./data to modify the current data directory owner as a mysql user.
Mysql installation is complete.
5. Start the mysql service and add and start the mysql Service
(1) execute the command: cd/usr/local/mysql/support-files
(2) execute the command cp my-medium.cnf/etc/my. cnf; cp mysql. server/etc/init. d/mysqld put the startup script to the boot initialization directory. If no my-medium.cnf exists (Version 5.5 exists, version 5.6 does not exist), run the command cp my-default.cnf/etc/my. cnf; cp mysql. server/etc/init. d/mysqld
(3) Modify/etc/my. cnf and/etc/init. d/mysqld file content. Replace the default configuration path/usr/local/mysql in the file content with the installation directory of mysql. Here, the installation directory is/usr/local/mysql, no need to modify. Configure the bin and data paths.
(4) run the command: service mysqld start to start the mysql service.
(5) execute the command: ps-ef | grep mysql. If you see the mysql service, it indicates that the startup is successful,
6. Modify the mysql root User Password. It is blank by default.
Run the command:/usr/local/mysql/bin/mysqladmin-u rootpassword 123456,123456 is the user password, which can be set as needed.
7. Place the mysql client in the default path
Run ln-s/usr/local/mysql/bin/mysql/usr/local/bin/mysql
Note: We recommend that you use soft links instead of directly copying package files to facilitate system installation of multiple versions of mysql.
8. Configure mysql Remote Access Permissions
(1) run the command:/usr/local/mysql/bin/mysql-u root-p, enter the logon password, and enter mysql
Note that the Console does not display the password when you enter the password.
(2) run the command: use mysql. Note that the semicolon is also part of the command.
(3) create a remote logon user and grant permissions. Run the following command: GRANT all privilegeson *. * to root @ "%" identified by '000000' WITH grant OPTION;
In the command, "root" is the remote login name, and "123456" is the password of the remote login user. The red line of the password is covered.
(4) execute the command: flush privileges; force refresh permission
Now, you can log on to mysql using the set remote user name and password on other hosts.
OK! Done!
The above is all the content of this article. I hope it will be helpful for your learning and support for helping customers.