Yum Installation-Install mysql--technical Support Tpshop Mall

Source: Internet
Author: User

# # Source Compilation Install Mysql take mysql-5.7.15.tar.gz as an example
Some of the issues involved in the installation need to be explained in advance:
All downloaded files will be saved in the/root directory
MySQL will run as a MySQL user and will be added to the service boot Autorun
MySQL will be installed in the/usr/local/mysql/directory
MySQL default installation uses the UTF8 character set
MySQL data and log files are saved in the/usr/local/mysql/data/directory
MySQL configuration file is saved in/USR/LOCAL/MYSQL/ETC/MY.CNF
Note that starting the Boost library from MySQL 5.7.5 is required
Install dependent packages
Yum-y Install gcc-c++ ncurses-devel cmake make perl gcc autoconf automake zlib libxml libgcrypt libtool Bison
、、、 Install dependent libraries
, installation of CMake and bison
Yum install-y CMake Bison ncurses
,, download Boost
wget http://ncu.dl.sourceforge.net/project/boost/boost/1.59.0/boost_1_59_0.tar.gz
Extract
Tar zxf boost_1_59_0.tar.gz
Move
MV Boost_1_59_0/usr/local/boost

# #建立 MySQL installation directory and users,
Mkdir-pv/usr/local/mysql
、、、 set up 4 directories for "Data", "tmp", "Log", "etc" in/usr/local/mysql
Cd/usr/local/mysql
mkdir Data tmp log etc
, set up groups, and users
Groupadd MySQL
Useradd-g mysql-s/usr/sbin/nologin MySQL
、、、 download MySQL
CD ~
wget http://mirrors.sohu.com/mysql/MySQL-5.7/mysql-5.7.16.tar.gz
、、、 unzip and enter the directory
Tar zxf mysql-5.7.16.tar.gz
CD mysql-5.7.16
、、、 Write a helper shell file to help us configure MySQL
Vim mysql_install.sh
、、、 The following is written on one line, do not wrap
cmake-dcmake_install_prefix=/usr/local/mysql-dmysql_unix_addr=/usr/local/mysql/tmp/mysql.sock-dmysql_datadir=/ Usr/local/mysql/data-dsysconfdir=/usr/local/mysql/etc-dmysql_user=mysql-ddefault_charset=utf8-ddefault_ Collation=utf8_general_ci-dwith_extra_charsets:string=utf8,gbk-dwith_debug=0-dwith_myisam_storage_engine=1- Dwith_innobase_storage_engine=1-denabled_local_infile=1-dwith_embedded_server=1-dmysql_user=mysql-dmysql_tcp_ Port=3306-dwith_boost=/usr/local/boost
、、、 just add the executable permission to the shell file:
chmod +x./mysql_install.sh
、、、 execution of shell files for software configuration and environmental testing
./mysql_install.sh
、、、 compiling the software and installing it
Make && make install
Error Stop ...
In addition, if an error is interrupted during the process, you need to
To delete the CMakeCache.txt file and then execute the mysql_install.sh file (do not perform an error if
Next two lines of instructions!!! ):
Make clean
Rm-f CMakeCache.txt or shell># unlink Cmakecache.tx

############################# #配置 ########################

。。。。 Using recursion, set the MySQL directory owner to the MySQL User:
Chown-r Mysql:mysql/usr/local/mysql

。。。。 If/ETC/MY.CNF exists, please delete
Unlink/etc/my.cnf

。。。。 Go to the MySQL installation directory
Cd/usr/local/mysql

。。。。 Rebuilding my.cnf files
CP support-files/my-default.cnf ETC/MY.CNF

。。。。 Optimize MySQL configuration According to the actual situation
Vim ETC/MY.CNF

For example, change the contents of MY.CNF to the following:
[Client]
Default-character-set = UTF8
Port = 3306
Socket =/usr/local/mysql/tmp/mysql.sock
[Mysqld]
DataDir =/usr/local/mysql/data
Port = 3306
Socket =/usr/local/mysql/tmp/mysql.sock
user = MySQL
Symbolic-links = 0
Pid-file =/usr/local/mysql/tmp/mysql.pid
Explicit_defaults_for_timestamp = True
Sql_mode = Error_for_division_by_zero,no_zero_date,no_zero_in_date,no_auto_create_user
Slow_query_log = On
Slow_query_log_file =/usr/local/mysql/log/slow.log
Long_query_time = 2
Log_error =/usr/local/mysql/log/mysql.err

Fourth Step:
。。。。 Initializing the basic table of MySQL
。。 5.7 Previous practices:
/usr/local/mysql/scripts/mysql_install_db--defaults-file=/usr/local/mysql/my.cnf--basedir=/usr/local/mysql-- Datadir=/usr/local/mysql/data--user=mysql

。。。。 5.7 And above practices:
;;;;--initialize generates a random password (~/.mysql_secret), and--initialize-insecure does not generate a password
/usr/local/mysql/bin/mysqld--initialize-insecure--basedir=/usr/local/mysql--datadir=/usr/local/mysql/data-- User=mysql

。。。。 Start MySQL
/usr/local/mysql/bin/mysqld_safe >/dev/null 2>&1 &

。。。。 Modify the root password of MySQL
/usr/local/mysql/bin/mysqladmin-u Root password Password

。。。。 Increased to boot boot
;;;; first set mysqld to service
Cp/usr/local/mysql/support-files/mysql.server/etc/rc.d/init.d/mysqld

。。。。 Then add the MYSQLD service to the startup item:
Chkconfig--add mysqld

。。。。 Set to self-boot:
Chkconfig--level 345 mysqld on

。。。。 Add the MySQL command to the environment variable
Path= $PATH:/usr/local/mysql/bin

。。。。 Can still be valid for reboot:
Echo ' path= $PATH:/usr/local/mysql/bin ' >>/ROOT/.BASHRC

。。。。 If you need to open port 3306
Iptables-i input-p TCP--dport 3306-j ACCEPT

。。。。 If the MYSQLD service is running correctly, but the execution of the MySQL command times the following error
:: Error 2202 (HY000): Can ' t connent ....
The solution is to create a soft link
Mkdir-pv/var/lib/mysql
Ln-s/usr/local/mysql/tmp/mysql.sock/var/lib/mysql/mysql.sock

For a few days, sorted out. Where there are errors, please correct me.

Yum Installation-Install mysql--technical Support Tpshop Mall

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.