Detailed tutorial for installing MySQL on Linux

Detailed tutorial for installing MySQL on Linux

MySQL downloads for all platforms are available at MySQL Downloads. Select the version of MySQL Community Server that you need and the corresponding platform.

MySQL - The MySQL server. You need this option unless you only want to connect to a MySQL server running on another machine.
MySQL-client - MySQL client program, used to connect to and operate the Mysql server.
MySQL-devel - Libraries and include files. If you want to compile other MySQL clients, such as Perl modules, you need to install this RPM package.
MySQL-shared - This package contains the dynamically loaded shared libraries (libmysqlclient.so*) that some languages ​​and applications need to use MySQL.
MySQL-bench - Benchmark and performance testing tool for the MySQL database server

Installation steps:
The official website provides two installation packages for download, one is rpm and the other is tar. Both methods are available, please choose your own.

First, let's introduce the installation steps of the rpm package:
Transfer the downloaded file to the server and put it in a folder.
Enter the file and execute the following command:

[root@host]# rpm -i MySQL-5.0.9-0.i386.rpm

MySQL-5.0.9-0.i386.rpm is the name of the file you downloaded.

The above process of installing the MySQL server will create a MySQL user and a MySQL configuration file my.cnf.
You can find all MySQL-related binaries in /usr/bin and /usr/sbin. All tables and databases will be created in the /var/lib/mysql directory

Tar package installation process:
mysql download address

Go in and click community, then click MySQL Community Server
Write the picture description here

As shown in the figure, position 1 is to select the previous version. Select the appropriate version according to your needs.
Position 2 is the Linux version under different systems. After selecting, drag the scroll bar to the bottom to download.

After downloading, transfer the tarball to the server.

1. Unzip

#Unzip tar -zxvf mysql-5.6.33-linux-glibc2.5-x86_64.tar.gz
#Copy the unzipped mysql directory cp -r mysql-5.6.33-linux-glibc2.5-x86_64 /usr/local/mysql


2. Add users and user groups

#Add user group groupadd mysql
#Add user mysql to user group mysql
useradd -g mysql mysql


3. Installation

cd /usr/local/mysql/ 
#Create data folder mkdir ./data/mysql
#Change file permissions chown -R mysql:mysql ./
#Install and specify the user and data folder location./scripts/mysql_install_db --user=mysql --datadir=/usr/local/mysql/data/mysql
#Copy mysql to the service automatic startup cp support-files/mysql.server /etc/init.d/mysqld
#Change the permissions to 755, that is, root can execute chmod 755 /etc/init.d/mysqld
#Copy the configuration file to etc, because the default startup first loads the configuration file from etc. cp support-files/my-default.cnf /etc/my.cnf

#Modify the startup script vi /etc/init.d/mysqld

#Modifications:
basedir=/usr/local/mysql/
datadir=/usr/local/mysql/data/mysql

#Start the service service mysqld start

#Test connection ./mysql/bin/mysql -uroot

#Add environment variables and edit /etc/profile so that you can use mysql commands anywhere export PATH=$PATH:/usr/local/mysql/bin


#Start mysql
service mysqld start
#Shut down mysql
service mysqld stop
#Restart mysql
service mysqld restart
#View the running status service mysqld status


4. Question
After the installation is complete, modify the root user password and perform related user configurations.

After completion, an error message is reported when using the tool to connect remotely. This is because the user permissions for the remote connection are not given.

Solution 1: Change the 'host' entry in the 'user' table of the 'mysql' database from 'localhost' to '%'.

use mysql;
select 'host' from user where user='root'; 
update user set host = '%' where user = 'root';
flush privileges;


Solution 2: Direct authorization

GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'youpassword' WITH GRANT OPTION;

Wonderful topic sharing:

MySQL different versions installation tutorial

MySQL 5.7 installation tutorials for various versions

MySQL 5.6 installation tutorials for various versions

mysql8.0 installation tutorials for various versions

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:
  • Detailed tutorial on installing Mysql5.7.19 on Centos7 under Linux
  • MySQL 5.7.19 (tar.gz) installation graphic tutorial under Linux
  • MySQL 5.6.27 Installation Tutorial under Linux
  • MySQL 8.0 installation tutorial under Linux
  • Detailed steps to install MySql 5.7.21 in Linux
  • Installation tutorial of MySQL 5.1 and 5.7 under Linux
  • How to install and configure the decompressed version of MySQL database under Linux system
  • MySQL 5.7 installation and configuration tutorial under Linux virtual machine
  • Detailed steps to install MySQL 5.6 X64 version under Linux

<<:  js canvas to realize the Gobang game

>>:  Hadoop 2.x vs 3.x 22-point comparison, Hadoop 3.x improvements over 2.x

Recommend

Use of Linux relative and absolute paths

01. Overview Absolute paths and relative paths ar...

A detailed explanation of how React Fiber works

Table of contents What is React Fiber? Why React ...

Detailed steps for creating a Vue scaffolding project

vue scaffolding -> vue.cli Quickly create a la...

Analysis of the principle of Vue nextTick

Table of contents Event Loop miscroTask (microtas...

CentOS7 configuration Alibaba Cloud yum source method code

Open the centos yum folder Enter the command cd /...

mysql 8.0.18 mgr installation and its switching function

1. System installation package yum -y install mak...

Windows system mysql5.7.18 installation graphic tutorial

MySQL installation tutorial for Windows system do...

VMware Workstation download and installation detailed tutorial

Virtual machines are very convenient testing soft...

How to manage cached pages in Vue

Table of contents Problem 1: Destruction 1. How t...

How to use MySQL binlog to restore accidentally deleted databases

Table of contents 1 View the current database con...

Analysis of the event loop mechanism of js

Preface As we all know, JavaScript is single-thre...

How to connect Navicat to the docker database on the server

Start the mysql container in docekr Use command: ...

How to remove the dividing line of a web page table

<br />How to remove the dividing lines of a ...