Summary of several MySQL installation methods and configuration issues

Summary of several MySQL installation methods and configuration issues

1. MySQL rpm package installation

# Download the installation source [root@localhost src]# wget https://dev.mysql.com/get/mysql-community-release-el7-5.noarch.rpm
# Installation source [root@localhost src]# rpm -ivh mysql-community-release-el7-5.noarch.rpm

2. MySQL yum tool installation

[root@localhost /]# yum install -y mysql-community-server
# View the installed file path [root@localhost /]# which mysql mysqld_safe mysqlbinlog mysqldump
/usr/bin/mysql
/usr/bin/mysqld_safe
/usr/bin/mysqlbinlog
/usr/bin/mysqldump

If you want to view the detailed file list contained in each installation package, you can use "rpm -ql software name" to view it. This command lists the file list and installation location of the current rpm package. as follows:

[root@localhost /]# rpm -ql openssl
/etc/pki/tls/misc/c_hash
/etc/pki/tls/misc/c_info
/etc/pki/tls/misc/c_issuer
/etc/pki/tls/misc/c_name
/usr/bin/openssl
/usr/share/doc/openssl-1.0.1e
/usr/share/doc/openssl-1.0.1e/CHANGES
.......

3. MySQL source code installation

# Install the packages required for compilation [root@localhost src]# yum install -y make gcc-c++ cmake bison-devel ncurses-devel gcc autoconf automake zlib* fiex* libxml*
# Download source code [root@localhost src]# wget https://cdn.mysql.com//archives/mysql-5.6/mysql-5.6.24.tar.gz
# Unzip the source package [root@localhost src]# tar xvf mysql-5.6.24.tar.gz
[root@localhost src]# cd mysql-5.6.24
# Compile and configure. This process will take 3 to 5 minutes [root@localhost mysql-5.6.24]# cmake \
-DCMAKE_INSTALL_PREFIX=/usr/local/mysql \
-DMYSQL_DATADIR=/data/mysql/data \
-DSYSCONFDIR=/etc \
-DWITH_MYISAM_STORAGE_ENGINE=1 \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DMYSQL_UNIX_ADDR=/tmp/mysql/mysql.sock \
-DMYSQL_TCP_PORT=3306 \
-DENABLED_LOCAL_INFILE=1 \
-DWITH_PARTITION_STORAGE_ENGINE=1 \
-DEXTRA_CHARSETS=all \
-DDEFAULT_CHARSET=utf8 \
-DDEFAULT_COLLATION=utf8_general_ci
# Compile and install # The compilation process takes about 30 to 50 minutes [root@localhost mysql-5.6.24] # make
[root@localhost mysql-5.6.24]# make install
# Set up MySQL user and group [root@localhost mysql-5.6.24]# groupadd mysql
[root@localhost mysql-5.6.24]# useradd -r -g mysql mysql
[root@localhost mysql-5.6.24]# cd /usr/local/mysql/
# Set permissions so mysql can modify files [root@localhost mysql]# chown -R mysql:mysql ./
[root@localhost mysql]# chown -R mysql:mysql /data/mysql/data
# Initialize the database # Note that the data directory set here should be the same as the directory specified by MYSQL_DATADIR previously [root@localhost mysql]# scripts/mysql_install_db --user=mysql -ldata=/data/mysql/data
# Restore the permission settings and modify the permissions of the corresponding directories for mysql to modify [root@localhost mysql]# chown -R root ./
[root@localhost mysql]# chown -R mysql data

The above example indicates that the MySQL software is installed in the /usr/local/mysql directory. The parameters used in this example and their meanings are as follows:

DCMAKE_INSTALL_PREFIX: indicates where MySQL is installed. In this example, it will be installed in the /usr/local/mysql directory.

DMYSQL_DATADIR: indicates the directory where MySQL data files are stored; DSYSCONFDIR: the directory where the configuration files are located;

DWITH_MYISAM_STORAGE_ENGINE: compile the MyISAM storage engine into the service;

DWITH_INNOBASE_STORAGE_ENGINE: compile the InnoDB storage engine into the service; DMYSQL_UNIX_ADDR:

DMYSQL_TCP_PORT: The default port; DENABLED_LOCAL_INFILE: Specifies whether to allow local execution of LOAD DATA

INFILE; DWITH_PARTITION_STORAGE_ENGINE: compile the partition engine into the service;

DEXTRA_CHARSETS: Allows the service to support all extended character sets; DDEFAULT_CHARSET: The default character set used by the service, set here to

UTF8; DDEFAULT_COLLATION: default sorting rule.

There are many parameters when compiling and installing MySQL. The detailed meaning and description of these parameters can be found in the official website: http://dev.mysql.com/doc/refman/5.5/en/source-configuration-options.html

The role of installed dependency packages:

gcc/g++: Starting from MySQL 5.6, you need to use g++ to compile; cmake: Starting from MySQL 5.5, use cmake for project management, and cmake version 2.8 or above is required; bison: The MySQL syntax parser needs to be compiled with bison; ncurses-devel: A development package for terminal operations; zlib: MySQL uses zlib for compression; libxml: Support for XML input and output methods; openssl: Use openssl secure socket communication;

dtrace: Used to diagnose MySQL problems.

Completing the above installation steps is not enough. You also need to add configuration options, start and stop scripts, etc. for MySQL.

cd /usr/local/mysql/
#Remove the comment lines in the configuration file and only display the valid lines grep -v "^#" my.cnf
#Put the startup script in the /etc/init.d directory cp support-files/mysql.server /etc/init.d/mysqld
#Add mysql as a system service chkconfig --add mysqld
service mysqld start
#At this time, the root user of MySQL has no password yet, so you should set a password for it. /usr/local/mysql/bin/mysql -u root -h 192.168.146.150 -p
#Since no password has been set, just press Enter. #Set the root user's password to 888888
set password = password('888888');
#After the setting is completed, enter quit to exit

Appendix: Summary of problems during installation

1.-bash:mysql:command not found

Because the path of the mysql command is under /usr/local/mysql/bin, when you use the mysql command directly, the system searches for this command under /usr/bin and cannot find it.

Solution: Use the following command to make a link

ln -s /usr/local/mysql/bin/mysql /usr/bin

2. Starting MySQL..The server quit without updating PID file ([FAILED]/mysql/Server03.mylinux.com.pid).

Solution:

Modify datadir in /etc/my.cnf to point to the correct mysql database file directory

3. ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)

Solution:

Create a new link or add the -S parameter to mysql to directly point to the location of mysql.sock.

ln -s /usr/local/mysql/data/mysql.sock /tmp/mysql.sock
/usr/local/mysql/bin/mysql -u root -S /usr/local/mysql/data/mysql.sock

The above is a summary of several MySQL installation methods and configuration issues introduced by the editor. I hope it will be helpful to everyone. If you have any questions, please leave me a message and the editor will reply to you in time. I would also like to thank everyone for their support of the 123WORDPRESS.COM website!

You may also be interested in:
  • MySQL 5.7.18 free installation version configuration tutorial
  • MySQL 5.7.17 installation and configuration graphic tutorial
  • MySQL 5.7.18 winx64 installation and configuration method graphic tutorial
  • mysql 5.7.18 winx64 free installation configuration method
  • MySQL 5.7.17 installation and configuration method graphic tutorial under win7
  • MySQL5.6.31 winx64.zip installation and configuration tutorial

<<:  Correct way to load fonts in Vue.js

>>:  Hbase Getting Started

Recommend

Ubuntu installation cuda10.1 driver implementation steps

1. Download cuda10.1: NVIDIA official website lin...

npm Taobao mirror modification explanation

1. Top-level usage 1. Install cnpm npm i -g cnpm ...

Summary of MySQL lock knowledge points

The concept of lock ①. Lock, in real life, is a t...

The concept of MySQL tablespace fragmentation and solutions to related problems

Table of contents background What is tablespace f...

WeChat applet uses canvas to draw clocks

This article shares the specific code of using ca...

A brief introduction to MySQL functions

Table of contents 1. Mathematical functions 2. St...

Summary of MySQL view principles and usage examples

This article summarizes the principles and usage ...

MySQL installation and configuration methods and precautions under Windows platform

2.1、msi installation package 2.1.1、Installation I...

Native js drag and drop function to create a slider example code

Drag and drop is a common function in the front e...

Vue realizes web online chat function

This article example shares the specific code of ...

MySQL: mysql functions

1. Built-in functions 1. Mathematical functions r...

Nodejs global variables and global objects knowledge points and usage details

1. Global Object All modules can be called 1) glo...

Talk about nextTick in Vue

When the data changes, the DOM view is not update...