Mysql installation (Using Generic Binaries), genericbinaries

Source: Internet
Author: User
Tags install perl

Mysql installation (Using Generic Binaries), genericbinaries

Mysql is Mysql 5.6.21 and is installed in common Linux. That is, most Linux platforms can install Mysql in this way.

1. Installation Steps

1. installation environment

1) Centos 7.0.1406 X86_64 or Centos 6.5 X86_64 are slightly different only in firewall policies!

2. Download Mysql, decompress Mysql, and create a soft connection, which is somewhat different from the official decompression path.

$ wget http://cdn.mysql.com/Downloads/MySQL-5.6/mysql-5.6.21-linux-glibc2.5-x86_64.tar.gz$ sudo tar zxvf mysql-5.6.21-linux-glibc2.5-x86_64.tar.gz -C /usr/local/src/$ sudo ln -s /usr/local/src/mysql-5.6.21-linux-glibc2.5-x86_64/ /usr/local/mysql

3. There are two installation methods.

Method 1: Install Mysql in the Mysql learning environment following the instructions of Mysql. For the following commands, see Installing MySQL on Unix/Linux Using Generic Binaries.

shell> groupadd mysqlshell> useradd -r -g mysql mysqlshell> cd /usr/localshell> tar zxvf /path/to/mysql-VERSION-OS.tar.gzshell> ln -s full-path-to-mysql-VERSION-OS mysqlshell> cd mysqlshell> chown -R mysql .shell> chgrp -R mysql .shell> scripts/mysql_install_db --user=mysqlshell> chown -R root .shell> chown -R mysql datashell> bin/mysqld_safe --user=mysql &# Next command is optionalshell> cp support-files/mysql.server /etc/init.d/mysql.server

Method 2: Customize the Mysql Data Storage path and use it in the deployment environment.

1) Create Mysql users and user groups

$ Sudo groupadd mysql $ sudo useradd-r-g mysql $ cd/usr/local/src/$ sudo chown-R mysql: mysql mysql-5.6.21-linux-glibc2.5-x86_64/# define mysql user and group $ ll total usage 4drwxr-xr-x. 13 mysql 4096 November 5 08:10 mysql-5.6.21-linux-glibc2.5-x86_64

2) create a storage location for the Mysql data file. If you use a data disk, mount it on your own.

$ Sudo mkdir-p/data/mysql # define the mysql data file storage address

3) initialize Mysql. for possible problems, refer to the troubleshooting methods at the bottom of the article.

$ Sudo/usr/local/mysql/scripts/mysql_install_db -- user = mysql -- basedir =/usr/local/mysql/-- datadir =/data/mysql/# initialize mysql

4) Configure my. cnf

$ sudo vi /usr/local/mysql/my.cnf 

This example only ensures normal operation, so you can configure the following three items.

  basedir = /usr/local/mysql  datadir = /data/mysql  port = 3306

Create a soft connection my. cnf to the/etc/directory

$ sudo ln -s /usr/local/mysql/my.cnf /etc/my.cnf

5) Start the Mysql Service

$ sudo /usr/local/mysql/support-files/mysql.server startStarting MySQL. SUCCESS! 

6) log on to Mysql

$ /usr/local/mysql/bin/mysqlWelcome to the MySQL monitor.  Commands end with ; or \g.Your MySQL connection id is 1Server version: 5.6.21 MySQL Community Server (GPL)Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved.Oracle is a registered trademark of Oracle Corporation and/or itsaffiliates. Other names may be trademarks of their respectiveowners.Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.mysql> 

Ii. boot

$ sudo chkconfig --add mysqld

Iii. Environment Variables

1) edit the profile file

$ sudo vi /etc/profile

2) Add the following information to the bottom of the profile

export PATH=$PATH:/usr/local/mysql/bin

3) the configuration file takes effect immediately

$ source /etc/profile

Iv. Mysql remote connection

Mysql> select user (); + ---------------- + | user () | + ---------------- + | root @ localhost | + ---------------- + 1 row in set (0.01 sec) mysql> grant all privileges on *. * to root @ '%' identified by "your password"; Query OK, 0 rows affected (0.00 sec) mysql> flush privileges; Query OK, 0 rows affected (0.00 sec)

5. Firewall Enabled

By default, iptables Management port is enabled for Centos 6.5.

Edit the iptables File

$ sudo vim /etc/sysconfig/iptables
Add port 3306 rules. Pay attention to port 11th rules.
# Firewall configuration written by system-config-firewall# Manual customization of this file is not recommended.*filter:INPUT ACCEPT [0:0]:FORWARD ACCEPT [0:0]:OUTPUT ACCEPT [0:0]-A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT-A INPUT -p icmp -j ACCEPT-A INPUT -i lo -j ACCEPT-A INPUT -m state --state NEW -m tcp -p tcp --dport 22 -j ACCEPT-A INPUT -m state --state NEW -m tcp -p tcp --dport 3306 -j ACCEPT-A INPUT -j REJECT --reject-with icmp-host-prohibited-A FORWARD -j REJECT --reject-with icmp-host-prohibitedCOMMIT
Restart the iptables service to connect to the instance remotely.
$ Sudo service iptables restartiptables: Set the chain to policy ACCEPT: filter [OK] iptables: clear firewall rules: [OK] iptables: uninstalling module: [OK] iptables: application Firewall Rules: [OK]

By default, the firewall management port is enabled for Centos 7.

1) check whether the port is enabled. If no port is configured before, no indicates that port 3306 is not open. Otherwise, yes indicates that port is open and can be accessed remotely from the Mysql client!

$ sudo firewall-cmd --query-port=3306/tcpno

2) temporarily enable port 3306

$ sudo firewall-cmd --add-port=3306/tcpsuccess

3) permanently enable port 3306

$ Sudo firewall-cmd -- permanent -- zone = public -- add-port = 3306/tcpsuccess $ sudo firewall-cmd -- reload # reload and configure success [john @ localhost ~] $ Sudo firewall-cmd -- zone = public -- list-all # view add result public (default, active) interfaces: eth0 sources: services: dhcpv6-client ssh ports: 3306/tcp 22/tcp masquerade: no forward-ports: icmp-blocks: rich rules:

Vi. troubleshooting

Question 1:

$ sudo scripts/mysql_install_db --user=mysql --basedir=/usr/local/mysql/ --datadir=/data/mysql/sudo: unable to execute scripts/mysql_install_db: No such file or directory

Solution: it is a coincidence to solve this problem. Remove sudo and prompt that there is a problem with the Perl parser. reinstall it.

$ sudo yum install perl$ sudo yum install perl-Data-Dumper.x86_64

Question 2:

$ sudo scripts/mysql_install_db --user=mysql --basedir=/usr/local/mysql/ --datadir=/data/mysql/Installing MySQL system tables.../usr/local/mysql//bin/mysqld: error while loading shared libraries: libaio.so.1: cannot open shared object file: No such file or directory

Solution:

$ sudo yum install libaio.x86_64

Question 3:

$ sudo support-files/mysql.server startStarting MySQL. ERROR! The server quit without updating PID file (/data/mysql/localhost.localdomain.pid).
Solution: this problem is especially prompted during the first startup. Simply put, I cannot be found. the cnf file is configured. copy cnf to/etc/or create a soft connection to the/etc/directory!

$ sudo cp my.cnf /etc/
I am a bit confused here. On the surface, mysql startup depends on/etc/my. cnf file, but you can delete/etc/my after mysql is started normally for the first time. cnf file. The file/usr/local/mysql/my can be loaded normally at the second startup. cnf file!


Reprinted please indicate the source: http://blog.csdn.net/johnnycode/article/details/40783553


References:

Install Mysql 5.6.19 on Centos7

How to compile and install Nginx1.6.0 + MySQL5.6.19 + PHP5.5.14 in CentOS 7.0

Firewall Configuration in RHEL7 (1)

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.