MySQL uninstall and install graphic tutorial under Linux

MySQL uninstall and install graphic tutorial under Linux

This is my first time writing a blog. I have been doing development for two years. I want to find something meaningful to do after work. I would like to share some experience gained during the development process. It can also be regarded as my own notes. Sometimes I can’t remember some things after not using them for a long time. Okay, enough nonsense. Next, I will explain the detailed steps of uninstalling and installing MySQL in Linux environment. This article takes MySQL installed by binary package (source code) as an example.

1. Uninstall MySQL database

1. Check the mysql service and shut down the service process

(1) After logging in to Linux, execute the service mysqld status or service mysql status command to check the MySQL service status. The status depends on the file name of the mysql script in the boot initialization directory. In my case, it is mysqld


(2) If the MySQL service is running, execute the service mysqld stop or service mysql stop command to stop the MySQL service, depending on the file name of the mysql script in the boot initialization directory. In my case, it is mysqld


2. Find the installation directory of MySQL and delete it completely

(1) Execute find / -name mysql to find directories related to mysql

(2) Execute rm -rf 'directory' to delete the found directory

3. Delete the mysql configuration file

(1) Execute the rm -rf /etc/my.cnf command to delete the /etc/my.cnf file


(2) Execute the rm -rf /etc/init.d/mysqld command to delete all files related to mysql under /etc/init.d/, which generally include mysql files or mysqld files. If mysql files exist, execute the rm -rf /etc/init.d/mysql command


4. Delete mysql users and user groups

(1) Execute the id mysql command to view MySQL users and user groups


(2) Execute the userdel mysql command to delete the MySQL user and user group


At this point, mysql uninstallation is complete!

2. Install 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 required version on the download page (if there is only the Windows version installation package after entering the download list, you can install the XSkyWalker browser to download it. The XSkyWalker download address is: https://www.jb51.net/softs/192435.html), as shown in the following figure:


(2) Scroll to the bottom of the page and download Linux - Generic (glibc 2.5) (x86, 64-bit) for 64-bit systems and Linux- Generic (glibc 2.5) (x86, 32-bit) for 32-bit systems.


2. Upload and decompress the MySQL installation package

Upload the downloaded MySQL installation package mysql-5.6.16-linux-glibc2.5-x86_64.tar.gz to the Linux host through the FTP tool (I uploaded it to the /usr/local/ directory here). Enter the directory where the installation package is located and execute the command: tar -zxvf mysql-5.6.16-linux-glibc2.5-x86_64.tar.gz to decompress the installation package.


3. Add system mysql user group and user

Execute the command: groupadd mysql and useradd -r -g mysql mysql


4. Install MySQL database

(1) Execute the command: cd /usr/local to enter the directory where the MySQL software is installed


(2) Execute the command: mv mysql-5.6.16-linux-glibc2.5-x86_64 mysql to rename the unzipped folder to mysql


(3) Execute the command: cd /usr/local/mysql to enter the MySQL installation directory


(4) Execute the command: chown -R mysql:mysql ./Change the owner of the current directory to the mysql user


(5) Execute the command: ./scripts/mysql_install_db --user=mysql to install the database


(6) Execute the command: chown -R root:root ./Change the owner of the current directory to the root user


(7) Execute the command: chown -R mysql:mysql ./data to change the owner of the current data directory to the mysql user


At this point, mysql installation is complete

5. Start the MySQL service and add the boot-up 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 to put the startup script in the boot initialization directory. If my-medium.cnf does not exist (version 5.5 exists, but version 5.6 does not), execute the command cp my-default.cnf/etc/my.cnf;cp mysql.server /etc/init.d/mysqld


(3) Modify the contents of the /etc/my.cnf and /etc/init.d/mysqld files, and replace all the default configuration paths /usr/local/mysql in the file contents with the installation directory of mysql. My installation directory is /usr/local/mysql and does not need to be modified. Mainly configure the bin and data paths.

(4) Execute the command: service mysqld start to start the MySQL service


(5) Execute the command: ps -ef|grep mysql to see that the MySQL service is started successfully, as shown in the figure:


6. Modify the root user password of mysql, which is empty by default

Execute the command : /usr/local/mysql/bin/mysqladmin -u rootpassword 123456, where 123456 is the user password and can be set according to your needs.


7. Put the mysql client in the default path

Execute the command: ln -s /usr/local/mysql/bin/mysql /usr/local/bin/mysql


Note: It is recommended to use a soft link instead of directly copying the package file to facilitate the installation of multiple versions of MySQL on the system

8. Configure MySQL remote access permissions

(1) Execute the command : /usr/local/mysql/bin/mysql -u root -p, enter the login password, and enter mysql.


Note that the console will not display the password when you enter it.

(2) Execute the command: use mysql; note that the semicolon is also part of the command.


(3) Create a remote login user and authorize it, and execute the command: grant all privileges on *.* to root @"%" identified by '123456' WITH GRANT OPTION;


The root in the command is the remote login name, 123456 is the remote login user password, and the password corresponds to the part covered by the red line in the middle

(4) Execute the command: flush privileges; Force refresh privileges


Now you can log in to MySQL on other hosts using the remote username and password you set.

OK! Done!

The above is the full content of this article. I hope it will be helpful for everyone’s study. I also hope that everyone will support 123WORDPRESS.COM.

You may also be interested in:
  • How to install and uninstall MySQL 5.7.11 on Mac
  • How to install and uninstall MySQL service under Windows (MySQL 5.6 zip decompression version installation tutorial)
  • Installation and uninstallation of MySQL 5.7 decompressed version and summary of common problems
  • Detailed explanation of installing and completely uninstalling mysql with apt-get under Ubuntu
  • Ubuntu 16.04.1 MySQL installation and uninstallation graphic tutorial
  • Detailed tutorial on MySql installation and uninstallation
  • If MYSQL is not completely uninstalled, its installation will fail.
  • Detailed installation and uninstallation tutorial for MySQL 8.0.12
  • Complete step-by-step record of MySQL 8.0.26 installation and uninstallation

<<:  How to install PostgreSQL11 on CentOS7

>>:  How to install nginx under Linux

Recommend

How to solve the high concurrency problem in MySQL database

Preface We all know that startups initially use m...

How to view and configure password expiration on Linux

With the right settings, you can force Linux user...

How to use resize to implement image switching preview function

Key Points The CSS resize property allows you to ...

How to use JS to check if an element is within the viewport

Preface Share two methods to monitor whether an e...

Examples and comparison of 3 methods for deduplication of JS object arrays

Table of contents 1. Comparison of data before an...

Analysis of the process of building a cluster environment with Apache and Tomcat

In fact, it is not difficult to build an Apache c...

MySQL installation tutorial under Centos7

MySQL installation tutorial, for your reference, ...

JavaScript history object explained

Table of contents 1. Route navigation 2. History ...

Detailed explanation of CSS pre-compiled languages ​​and their differences

1. What is As a markup language, CSS has a relati...

How to set underline in HTML? How to underline text in HTML

Underlining in HTML used to be a matter of enclos...

Detailed steps to install python3.7 on CentOS6.5

1. Download Python 3 wget https://www.python.org/...

Web Design: Script Materials Reconstruct User Experience

<br />Original text: http://blog.rexsong.com...

Explanation of MySQL's horizontal and vertical table partitioning

In my previous article, I said that the optimizat...