Install MySQL5.7.13 in CentOS 6.8 using a common binary method

Source: Internet
Author: User
Tags mysql commands

Install MySQL5.7.13 in CentOS 6.8 using a common binary method

Installation environment: CentOS 6.8
Objective: To install MySQL5.7.13 using the Generic Binary (Generic Binary) Method
Required Software: mysql-5.7.13-linux-glibc2.5-x86_64.tar (Please download from the MySQL official website)
Steps:
1. Create a mysql user and a mysql Group
Groupadd-g 3306 mysql
Useradd-g mysql-u 3306-s/sbin/nologin-M mysql
Id mysql # Check whether the creation is successful


2. Create a MySQL data directory using logical volumes.
[Root @ localhost] fdisk/dev/sda
N # create a partition
Enter # use the default track initial number for the new partition
+ 2G # create a 2G Partition
T # modify the partition type
9 # create the ninth partition on my system, so press
8e # change to LVM type
W # Save and exit
[Root @ localhost] partprobe # notify the kernel to read the Partition Table
Reboot # restart the Linux System
Pvcreate/dev/sda9
Vgcreate myvg/dev/sda9
Lvcreate-L 1G-n mydata myvg # create a logical volume
Mke2fs-j/dev/myvg/mydata # format the logical volume as an ext3 File System
Mkdir/mydata # create a mount directory
Modify/etc/fstab settings to automatically mount/dev/myvg/mydata upon startup
Vim/etc/fstab
Add the last line/dev/myvg/mydata ext3 defaults 0 0
Mount-a # mount a logical volume
Df # Check whether the logical volume is attached
Chown-R mysql. mysql/mydata/data/
Chmod-R 750/mydata/data # these two steps are critical and are directly related to whether you have the permission to read and write data in the/mydata/data/directory during database initialization.


3. decompress the mysql universal binary package to the/usr/local directory.

Cd/usr/local
Tar xf mysql-5.7.13-linux-glibc2.5-x86_64.tar
Two compressed packages are added after decompression. The mysql-test-5.7.13-linux-glibc2.5-x86_64.tar.gz package is not deleted.
Tar xf mysql-5.7.13-linux-glibc2.5-x86_64.tar.gz
Ln-sv mysql-5.7.13-linux-glibc2.5-x86_64 mysql # create a soft link
Cd mysql # Found these directories bin COPYING lib README share support-files

It is important to modify the permission chown-R mysql. mysql. #. Do not forget to modify the permission.
The most important directories are support-files and bin.
Support-files contains the mysql sample configuration file and Service Startup Script.
Bin stores important mysql commands (used for database initialization, backup, replication, etc)
The following command is used to initialize database version 5.7 before/bin/mysql_install_db. After version 5.7, this command is discarded. Use/bin/mysqld to initialize the database.
Bin/mysqld -- initialize-insecure -- user = mysql -- datadir =/mydata/data # initialize the database and specify the data DIRECTORY -- initialize-insecure is used to initialize the database without generating a password, if -- initialize is used, a random initial password is generated for the database. In the production environment, you must generate a password for mysql.
Cp/support_files/mysql. server/etc/init. d/mysqld # provide service scripts
4. Provide the mysql configuration file
This is my configuration file, which only provides the simplest configuration. You can configure the relevant parameters as needed.
Less/etc/my. cnf
[Client]
Port = 3306
Socket =/tmp/mysql. sock
[Mysqld]
Datadir =/mydata/data/
Port = 3306
Socket =/tmp/mysql. sock
Key_buffer_size = 16 M
Max_allowed_packet = 8 M
5. Start the database
Service mysqld start # If OK is displayed, the startup is successful.
Port netstat-tulnp #3306 is indeed in the listening status.
Mysql-uroot-p # because there is no password, you can directly press enter to connect to mysql. The following interface appears, indicating that the operation is successful.
Welcome to the MySQL monitor. Commands end with; or \ g.
Your MySQL connection id is 2
Server version: 5.7.13 MySQL Community Server (GPL)


Copyright (c) 2000,201 3, Oracle and/or its affiliates. All rights reserved.


Oracle is a registered trademark of Oracle Corporation and/or its
Affiliates. Other names may be trademarks of their respective
Owners.


Type 'help; 'or' \ H' for help. type' \ C' to clear the current input statement.
Mysql> show databases;
+ -------------------- +
| Database |
+ -------------------- +
| Information_schema |
| Mysql |
| Performance_schema |
| Sys |
+ -------------------- +
4 rows in set (0.00 sec)


Mysql> create database mydb
->;
Query OK, 1 row affected (0.00 sec)


Mysql> use mydb;
Database changed
Mysql> create table mytb (id int auto_increment primary key );
Query OK, 0 rows affected (0.02 sec)
Done.

This article permanently updates the link address:

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.