Online Linux installation MySQL service is divided into two installation methods:
① source installation, the advantage is that the installation package is relatively small, only about dozens of M, the disadvantage is that the installation depends on the library, installation time is long, the installation step is complicated and error-prone;
② using the official compiled binary file installation, the advantage is the installation speed, installation steps simple, the disadvantage is that the installation package is large, about 300M (5.7 version is about 600M),
For the second method, I did a day, no fruit, to a certain link is not able to go through, the eldest brother also do not let, separated a few days boss and commanded me in the production server installed MySQL, this time I will follow the first method of source installation mode
Download the source installation package
http://dev.mysql.com/downloads/mysql/Select for linux download source installation package (those not larger than 100M)
install MySQLPreparing the installation Environment
First check if MySQL has been installed:
[Email protected] src]# Rpm-qa | grep MySQL
If you do, uninstall the previously installed MySQL:
[[email protected] src]# rpm-e--nodeps xxx (xxx is search result)
and delete all the relevant files:
/etc/my.cnf
Compiling and installing
Install the packages needed to compile the code
[Email protected] src]# yum-y install make gcc-c++ cmake bison-devel ncurses-devel Libaio
[email protected] src]# Yum install Libaio libaio-devel-y
[email protected] src]# Yum install perl-data-dumper-y
[email protected] src]# Yum install net-tools-y
Unzip the installation package and compile the installation
[Email protected] src]# tar xvf mysql-5.7.4-m14.tar.gz
[Email protected] src]# CD mysql-5.7.4
[[email protected] mysql-5.7.4] #cmake \
-dcmake_install_prefix=/usr/local/mysql \
-dmysql_datadir=/usr/local/mysql/data \
-DSYSCONFDIR=/ETC \
-dwith_myisam_storage_engine=1 \
-dwith_innobase_storage_engine=1 \
-dwith_memory_storage_engine=1 \
-dwith_readline=1 \
-dmysql_unix_addr=/var/lib/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
Common parameters explained:
Cmake_install_prefix: Specifies the installation directory of the MySQL program, default/usr/local/mysql
Default_charset: Specifies the server default character set, default Latin1
Default_collation: Specifies the default proofing rules for the server, default Latin1_general_ci
Enabled_local_infile: Specifies whether to allow load DATA INFILE to be executed locally, by default off
With_comment: Specifying compilation Notes Information
With_xxx_storage_engine: Specifies a storage engine that is statically compiled to MySQL, and the Myisam,merge,member and CSV four engines are compiled to the server by default and do not require special designation.
Without_xxx_storage_engine: Specifying a storage engine that does not compile
Sysconfdir: Initialize parameter file directory
Mysql_datadir: Data Files directory
Mysql_tcp_port: Service port number, default 3306
Mysql_unix_addr:socket file path, default/tmp/mysql.sock
Precautions
Starting the boost library from MySQL 5.7.5 is required, download the Boost library, copy it to the/usr/local/boost directory after decompression, and then cmake and add options to the following options-dwith_boost=/usr/local/boost
(Download: http://sourceforge.net/projects/boost/files/boost/) to view the installation package version when installing
Demand boost1.57.0
Wget-c http://liquidtelecom.dl.sourceforge.net/project/boost/boost/1.57.0/boost_1_57_0.tar.gz
Compile execution
[[email protected] src]# make && make install (wait a while)
At this point, MySQL installation is complete
Check if the system already has a MySQL user and if not, create
[Email protected] mysql-5.7.4]# CAT/ETC/PASSWD | grep MySQL
[Email protected] mysql-5.7.4]# Cat/etc/group | grep MySQL
Create user (but not log in with MySQL account)
[Email protected] mysql-5.7.4]# Groupadd mysql-s/sbin/nologin
[[email protected] mysql-5.7.4]# useradd-g MySQL MySQL
Modify Permissions
[Email protected] mysql-5.7.4]# chown-r mysql:mysql/usr/local/mysql
At this point, MySQL installation is complete
Configuration
Go to installation path
[Email protected] mysql-5.7.4]# Cd/usr/local/mysql
Enter the installation path, execute the initialization configuration script, and create the system's own database and table. To initialize the operation with root, add the –user=mysql parameter, generate a random password (note to save login)
[Email protected] mysql]# scripts/mysql_install_db--basedir=/usr/local/mysql--datadir=/usr/local/mysql/data-- User=mysql
Note: When starting the MySQL service, will be in a certain order to search my.cnf, first in the/etc directory, find will search "$basedir/my.cnf", in this case is/usr/local/mysql/ MY.CNF, this is the default location for the new MySQL configuration file!
Note: After the minimum installation of the CentOS 7 operating system is complete, there will be a my.cnf in the/etc directory, you need to rename this file to another name, such as:/etc/my.cnf.bak (get rid of it), otherwise, The file will interfere with the correct configuration of the source installation of MySQL, causing the failure to start.
After updating the system with Yum Update, you need to check if there is a my.cnf in the/etc directory, and if so, rename it to something else. Otherwise, MySQL will start with this configuration file, which may cause problems such as an inability to start properly.
Add a firewall (can save)
[Email protected] mysql]# firewall-cmd--zone=public--add-port=3306/tcp--permanent
[Email protected] mysql]# Firewall-cmd--reload
start MySQL
Add services, Copy service scripts to the INIT.D directory, and set boot boot
[email protected] mysql]# CP Support-files/mysql.server/etc/init.d/mysql
[[email protected] mysql]# chkconfig MySQL on
[[Email protected] mysql]# service MySQL start--start MySQL
See if MySQL started successfully
[Email protected] mysql]# NETSTAT-LNTP | grep 3306
If MySQL does not start successfully, view the error log under directory/usr/local/mysql/data
[[email protected] data]# tail Localhost.localdomain.err (Localhost.localdomain is host name)
If the log directory is not generated, the MySQL installation does not succeed (recompile the installation once)
Restart MySQL
First kill the MySQL process
[Email protected] 3306]# Pkill mysqld
Then check if the MySQL process has been killed
[Email protected] 3306]# NETSTAT-LNTP | grep 3306
The shell has no output at this point, indicating that the MySQL process has been killed
Then restart MySQL and check again to see if it started successfully.
[[Email protected] 3306]# service MySQL start
[Email protected] 3306]# NETSTAT-LNTP | grep 3306
Add
Startup/restart/stop of MySQL service
Start the MySQL service
# service Mysqld Start
Restart MySQL Service
# Service Mysqld Restart
Stop MySQL Service
# Service Mysqld Stop
Accessing the MySQL Database
Connect MySQL, enter the random password generated by the initialization
# mysql-uroot-p
Change root new password such as 123456
mysql> alter user ' root ' @ ' localhost ' identified by ' 123456 ';
Mysql> quit;
Mysql> exit; (with the best effect, it is the MySQL connection)
Reconnect MySQL with the new password
# mysql-uroot-p
Windows Connectivity Linux MySQL report (10061) error
1, view: Netstat-an|grep 3306 is empty, the description is not listening.
Workaround: Modify/etc/my.cnf to comment out the skip-networking, and then run Netstat-an|grep 3306 to see it.
2, for the server, the preferred firewall must allow 3306 port through, can be tested on the client by Telnet to the port.
(You can turn off Firewall service iptables stop)
3, set up for remote access users, you must first authorize the user to allow remote access.
#mysql-uroot-p
Mysql>grant all on root.* to "identified by" 123456 ";
------------------------------------------------------reference Documentation--------------------------------------
CentOS 7 under source installation MySQL 5.6:http://www.linuxidc.com/linux/2015-06/119354.htm
CentOS 6.6 Under source code compilation install MySQL 5.7.5:http://www.linuxidc.com/linux/2015-08/121667.htm
here is a small series of carefully selected MySQL-related content to see if it helps :
Linux Installation compiled MySQL5.5.28 http://www.linuxidc.com/Linux/2015-08/121533.htm
Linux under MySQL 5.6.23 installation http://www.linuxidc.com/Linux/2015-07/119934.htm
MySQL5.7.3.0 Installation Configuration Illustration tutorial Http://www.linuxidc.com/Linux/2014-10/108397.htm
Install MySQL http://www.linuxidc.com/Linux/2014-05/102366.htm under Ubuntu 14.04
"MySQL authoritative guide (original book 2nd edition)" Clear Chinese scanning version PDF http://www.linuxidc.com/Linux/2014-03/98821.htm
Ubuntu 14.04 LTS installation lnmp nginx\php5 (PHP-FPM) \mysql http://www.linuxidc.com/Linux/2014-05/102351.htm
Build MySQL master server http://www.linuxidc.com/Linux/2014-05/101599.htm under Ubuntu 14.04
Ubuntu 12.04 LTS builds a highly available distributed MySQL cluster http://www.linuxidc.com/Linux/2013-11/93019.htm
Ubuntu 12.04 under source code installation MySQL5.6 and Python-mysqldb http://www.linuxidc.com/Linux/2013-08/89270.htm
MySQL-5.5.38 Universal Binary Installation http://www.linuxidc.com/Linux/2014-07/104509.htm
For more information on CentOS, see the CentOS feature page http://www.linuxidc.com/topicnews.aspx?tid=14
CentOS 7 under source installation MySQL 5.7