Install MySQL
Several common installation packages for MySQL: rpm, source code, binary-free compilation
Cd/usr/local/src
wget http://mirrors.sohu.com/mysql/MySQL-5.6/mysql-5.6.35-linux-glibc2.5-x86_64.tar.gz
Tar zxvf mysql-5.6.35-linux-glibc2.5-x86_64.tar.gz
MV Mysql-5.6.35-linux-glibc2.5-x86_64/usr/local/mysql
Cd/usr/local/mysql
Useradd MySQL
mkdir/data/
./scripts/mysql_install_db--user=mysql--datadir=/data/mysql
CP SUPPORT-FILES/MY-DEFAULT.CNF/ETC/MY.CNF
CP Support-files/mysql.server/etc/init.d/mysqld
Vi/etc/init.d/mysqld
Define Basedir and DataDir
/etc/init.d/mysqld start
Experimental process
[[email protected] ~]# cd/usr/local/src///Recommended deployment program installed in this directory
[[email protected] src]# uname-a//can see whether the computer is 32-bit or 64-bit
Linux lyon-01 3.10.0-514.el7. x86_64 #1 SMP Tue Nov 16:42:41 UTC x86_64 x86_64 x86_64 gnu/linux
[Email protected] src]# wget http://mirrors.sohu.com/mysql/MySQL-5.6/mysql-5.6.35-linux-glibc2.5-x86_64.tar.gz Download the 64-bit version of the 5.6 package. Larger, may need to wait
[[Email protected] src]# tar zxvf mysql-5.6.35-linux-glibc2.5-x86_64.tar.gz//Unzip
[Email protected] src]# MV Mysql-5.6.35-linux-glibc2.5-x86_64/usr/local/mysql
Move the MySQL directory to/usr/local/and change the name to MySQL.
[[Email protected] local]# CD mysql///Make sure you have MySQL directory before this
[[email protected] mysql]# ls
Bin data include man README share Support-files
COPYING docs lib Mysql-test scripts sql-bench
[[email protected] mysql]# useradd mysql add user mysql
[[email protected] mysql]# mkdir/data/Create directory to hold data
[[email protected] mysql]#./scripts/mysql_install_db--user=mysql--datadir=/data/mysql//initialization
FATAL Error:please Install the following Perl modules before executing./SCRIPTS/MYSQL_INSTALL_DB:
Data::D Umper here has reported a mistake, can search, can also be Yum list fuzzy search
[email protected] mysql]# Yum list |grep perl |grep-i dumper
perl-data-dumper.x86_64 2.145-3.EL7 Base
Perl-data-dumper-concise.noarch 2.020-6.el7 Epel
Perl-data-dumper-names.noarch 0.03-17.el7 Epel
Perl-xml-dumper.noarch 0.81-17.EL7 Base
-------There will be a couple of packages that can be installed sequentially or installed
[email protected] mysql]# yum install-y perl-data-dumper.x86_64//This bag
[Email protected] mysql]#/scripts/mysql_install_db--user=mysql--datadir=/data/mysql
echo $?
[email protected] mysql]# CP support-files/my-default.cnf/etc/my.cnf
The system itself comes with a my.cnf file we can change as follows:
[Mysqld]
Datadir=/data/mysql//Only modify here
Socket=/tmp/mysql.sock
# Disabling Symbolic-links is recommended to prevent assorted security risks
Symbolic-links=0
# Settings user and group was ignored when Systemd was used.
# If you need to run mysqld under a different user or group,
# Customize your systemd unit file for mariadb according to the
# instructions in HTTP://FEDORAPROJECT.ORG/WIKI/SYSTEMD
[Mysqld_safe]
#log-error=/var/log/mariadb/mariadb.log//Notes
#pid-file=/var/run/mariadb/mariadb.pid//Notes
#
# include all files from the Config directory
#
#!includedir/etc/my.cnf.d//Notes
Save to exit.
Startup script Section
[[email protected] mysql]# ls support-files/
Binary-configure Magic my-default.cnf mysqld_multi.server mysql-log-rotate mysql.server
[email protected] mysql]# CP support-files/mysql.server/etc/init.d/mysqld
[Email protected] mysql]# Vi/etc/init.d/mysqld
You can change this place.
Basedir=/usr/local/mysql
Datadir=/data/mysql
Save exit
Configure boot-up
[Email protected] mysql]# chkconfig--add mysqld
[Email protected] mysql]# chkconfig--list
Note: This output shows only the SysV service and does not contain the native SYSTEMD service. SysV configuration data may be overwritten by native SYSTEMD configuration.
If you would like to list the SYSTEMD service, please do ' systemctl list-unit-files '.
To view services enabled for a specific target, perform
' Systemctl list-dependencies [target] '.
Mysqld 0: Off 1: Off 2: Open 3: Open 4: Open 5: Open 6: Off service Open
Netconsole 0: Off 1: Off 2: Off 3: Off 4: off 5: off 6: Off
Network 0: Off 1: Off 2: Open 3: Open 4: Open 5: Open 6: Off
Service Startup:
[[Email protected] mysql]# service mysqld start
Starting mysql.logging to '/data/mysql/lyon-01.err '.
.. success! Success Description Service started successfully
[[Email protected] mysql]# PS aux |grep mysql
Root 4190 0.0 0.1 11760 1584 pts/1 S 15:09 0:00/bin/sh/usr/local/mysql/bin/mysqd_safe--datadir=/data/m Ysql--pid-file=/data/mysql/lyon-01.pid
MySQL 4325 10.0 44.6 973044 450676 pts/1 Sl 15:09 0:02/usr/local/mysql/bin/mysqld--basedir=/usr/local/mysql-- Datadir=/data/mysql--plugin-dir=/usr/local/mysql/lib/plugin--user=mysql--log-error=/data/mysql/lyon-01.err-- Pid-file=/data/mysql/lyon-01.pid--socket=/tmp/mysql.sock
Root 4353 0.0 0.0 112664 976 pts/1 s+ 15:09 0:00 grep--color=auto MySQL
[Email protected] mysql]# NETSTAT-LNPT
Active Internet connections (only servers)
Proto recv-q send-q Local address Foreign address State Pid/program Name
TCP 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 1384/sshd
TCP 0 0 127.0.0.1:25 0.0.0.0:* LISTEN 1806/master
TCP6 0 0::: 3306:::* LISTEN 4325/mysqld
TCP6 0 0::: $:::* LISTEN 1384/sshd
TCP6 0 0:: 1:25:::* LISTEN 1806/master
Let's say we don't have a startup script, we start with the following method
[[Email protected] mysql]# service mysqld stop//stop services
Shutting down MySQL. success!
[[Email protected] mysql]# PS aux |grep mysqld
Root 4392 0.0 0.0 112664 972 PTS/1 s+ 15:17 0:00 grep--color=auto mysqld//already stopped
[Email protected] mysql]#/usr/local/mysql/bin/mysqld_safe--defaults-file=/etc/my.cnf--user=mysql--datadir=/data /mysql &//Use this command, and put it in the background to execute
[1] 4401
[Email protected] mysql]# 170926 15:19:54 mysqld_safe Logging to '/data/mysql/lyon-01.err '.
170926 15:19:55 Mysqld_safe starting mysqld daemon with databases From/data/mysql
[Email protected] mysql]#!ps
PS aux |grep mysqld//See if it has been started
Root 4401 0.0 0.1 113256 1584 pts/1 S 15:19 0:00/bin/sh/usr/local/mysql/bin/mysqld_safe--defaults-file= /ETC/MY.CNF--user=mysql--datadir=/data/mysql
MySQL 4524 1.4 44.5 973044 449500 pts/1 Sl 15:19 0:01/usr/local/mysql/bin/mysqld--defaults-file=/etc/my.cnf- -basedir=/usr/local/mysql--datadir=/data/mysql--plugin-dir=/usr/local/mysql/lib/plugin--user=mysql--log-error= /data/mysql/lyon-01.err--pid-file=/data/mysql/lyon-01.pid--socket=/tmp/mysql.sock
Root 4552 0.0 0.0 112664 976 pts/1 r+ 15:21 0:00 grep--color=auto mysqld
[[email protected] mysql]#!net//Look at the MySQL port
Netstat-lnpt
Active Internet connections (only servers)
Proto recv-q send-q Local address Foreign address State Pid/program Name
TCP 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 1384/sshd
TCP 0 0 127.0.0.1:25 0.0.0.0:* LISTEN 1806/master
TCP6 0 0::: 3306:::* LISTEN 4524/mysqld
TCP6 0 0::: $:::* LISTEN 1384/sshd
TCP6 0 0:: 1:25:::* LISTEN 1806/master
How do I close it?
[[email protected] support-files]#/etc/init.d/mysqld stop
or Killall mysqld.
Try not to kill the PID method implementation, but it is recommended to use killall more secure
The database reads and writes quickly, if you kill, the data in memory may be lost, but Killall will not, it will slowly write to disk and then stop. A large amount of data can be a bit longer, but it's safe.
This article is from the "13348833" blog, please be sure to keep this source http://13358833.blog.51cto.com/13348833/1968907
CENTOS7 under Lamp environment to build--mysql installation