Detailed steps to install MySql 5.7.21 in Linux

Detailed steps to install MySql 5.7.21 in Linux

Preface

The most widely used database in Linux is MySQL. This article will give you a detailed introduction on the steps to install MySql 5.7.21 in Linux. The steps are introduced in great detail in the article, which has a certain reference value for your study or work. Let's take a look at the detailed introduction.

1: Go to the MySQL official website to download the latest MySQL package mysql-5.7.21-linux-glibc2.12-x86_64

Official download address: https://dev.mysql.com/downloads/mysql/

Download address: https://www.jb51.net/softs/38849.html

2: Unzip the mysql compressed package in linux /usr/local/ and rename it to mysql

cd /usr/local/
tar -xzvf mysql compression package name

3. Create the user group mysql, create the user mysql and add it to the user group mysql, and grant read and write permissions

groupadd mysql -- create mysql user group
useradd -r -g mysql mysql --Create mysql user and add it to the mysql user group
chown -R mysql mysql/ -- Assign mysql directory access rights to the myql user
chgrp -R mysql mysql/ -- Change the user group of the mysql directory to belong to the mysql group

Note:

chmod command

Used to change the access permissions of a file or directory. Users use it to control access permissions for files or directories.

chgrp Command

Changes the group to which a file or directory belongs.

-R processes all files in the specified directory and its subdirectories

4: Create a configuration file, save and exit

vim /etc/my.cnf
#Copy the following content [client]
port = 3306
socket = /tmp/mysql.sock
[mysqld]
character_set_server=utf8
init_connect='SET NAMES utf8'
basedir=/usr/local/mysql
datadir=/usr/local/mysql/data
socket=/tmp/mysql.sock
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
# case insensitive lower_case_table_names = 1
sql_mode=STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION
max_connections=5000

default-time_zone = '+8:00'

Five: Initialize the database

#Install this first, otherwise the initialization may report an error yum install libaio
#Manually edit the log file. Don't write anything. Just save and exit cd /var/log/
vim mysqld.log
:wq
chmod 777 mysqld.log
chown mysql:mysql mysqld.log
/usr/local/mysql/bin/mysqld --initialize --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data --lc_messages_dir=/usr/local/mysql/share --lc_messages=en_US

6: View the initial password

cat /var/log/mysqld.log

The last line: root@localhost: This is the initial password

7: Start the service, enter mysql, change the initial password, and run the remote connection

#If you are prompted that you must change the password before you can proceed, execute the following operation: set password = password ('new password');

flush privileges;

UPDATE `mysql`.`user` SET `Host` = '%', `User` = 'root' WHERE (`Host` = 'localhost') AND (`User` = 'root');

#Then perform the following operations to start the mysql service and set relevant permissions cd /var/run/

mkdir mysqld

chmod 777 mysqld

cd mysqld

vim mysqld.pid

chmod 777 mysqld.pid

chown mysql:mysql mysqld.pid 

/usr/local/mysql/support-files/mysql.server start

/usr/local/mysql/bin/mysql -uroot -p The initial password you saw above # The following is the sql statement after entering the database use mysql;

 UPDATE `mysql`.`user` SET `Host`='%', `User`='root', `Select_priv`='Y', `Insert_priv`='Y', `Update_priv`='Y', `Delete_priv`='Y', `Create_priv`='Y', `Drop_priv`='Y', `Reload_priv`='Y', `Shutdown_priv`='Y', `Process_priv`='Y', `File_priv`='Y', `Grant_priv`='Y', `References_priv`='Y', `Index_priv`='Y', `Alter_priv`='Y', `Show_db_priv`='Y', `Super_priv`='Y', `Create_tmp_table_priv`='Y', `Lock_tables_priv`='Y', `Execute_priv`='Y', `Repl_slave_priv`='Y', `Repl_client_priv`='Y', `Create_view_priv`='Y', `Show_view_priv`='Y', `Create_routine_priv`='Y', `Alter_routine_priv`='Y', `Create_user_priv`='Y', `Event_priv`='Y', `Trigger_priv`='Y', `Create_tablespace_priv`='Y', `ssl_type`='', `ssl_cipher`='', `x509_issuer`='', `x509_subject`='', `max_questions`='0', `max_updates`='0', `max_connections`='0', `max_user_connections`='0', `plugin`='mysql_native_password', `authentication_string`='*6BB4837EB74329105EE4568DDA7DC67ED2CA2AD9', `password_expired`='N', `password_last_changed`='2017-11-20 12:41:07', `password_lifetime`=NULL, `account_locked`='N' WHERE (`User`='root');

 flush privileges;

8: Automatically start the machine

cd /usr/local/mysql/support-files
cp mysql.server /etc/init.d/mysqld
chkconfig --add mysqld

9: Use the service mysqld command to start/stop the service

su -mysql
service mysqld start/stop/restart
Remote user creation grant all privileges on *.* to 'new username'@'%' identified by 'new password';
flush privileges;
Add system path vim /etc/profile
export PATH=/usr/local/mysql/bin:$PATH
source /etc/profile

Use navicat to enter the user password to connect to mysql successfully!

Summarize

The above is the full content of this article. I hope that the content of this article will have certain reference learning value for your study or work. If you have any questions, you can leave a message to communicate. Thank you for your support for 123WORDPRESS.COM.

You may also be interested in:
  • MySQL 5.7.25 installation and configuration method graphic tutorial
  • MySQL 5.7.27 winx64 installation and configuration method graphic tutorial
  • MySQL 5.7.27 installation and configuration method graphic tutorial
  • Win32 MySQL 5.7.27 installation and configuration method graphic tutorial
  • MySQL 5.7.27 installation and configuration method graphic tutorial
  • MySql 5.7.20 installation and configuration of data and my.ini files
  • Detailed tutorial for installing mysql5.7.21 under Windows system
  • MySQL 5.7.20 Green Edition Installation Detailed Graphic Tutorial
  • MySQL 5.7.20 installation and configuration method graphic tutorial under Windows
  • MySQL 5.7.25 compressed version installation and configuration method graphic tutorial

<<:  How to query or obtain images in a private registry

>>:  JavaScript to show and hide images

Recommend

JavaScript DOMContentLoaded event case study

DOMContentLoaded Event Literally, it fires after ...

HTML imitates Baidu Encyclopedia navigation drop-down menu function

HTML imitates the Baidu Encyclopedia navigation d...

How to use resident nodes for layer management in CocosCreator

CocosCreator version: 2.3.4 Most games have layer...

Linux loading vmlinux debugging

Loading kernel symbols using gdb arm-eabi-gdb out...

Docker Gitlab+Jenkins+Harbor builds a persistent platform operation

CI/CD Overview CI workflow design Git code versio...

Detailed explanation of how to access MySQL database remotely through Workbench

Preface Workbench is installed on one computer, a...

Troubleshooting of master-slave delay issues when upgrading MySQL 5.6 to 5.7

Recently, when upgrading the Zabbix database from...

In-depth explanation of the style feature in Vue3 single-file components

Table of contents style scoped style module State...

A brief discussion on the whole process of Vue's first rendering

Table of contents 1. Vue initialization vue entry...

Detailed installation and uninstallation tutorial for MySQL 8.0.12

1. Installation steps for MySQL 8.0.12 version. 1...

A brief analysis of the count tracking of a request in nginx

First, let me explain the application method. The...

Summary of two methods to implement vue printing function

Method 1: Install the plugin via npm 1. Install n...

Teach you how to get the pointer position in javascript

The method of obtaining the position of the point...

CentOS 6 uses Docker to deploy redis master-slave database operation example

This article describes how to use docker to deplo...