CENTOS7 installation mysql5.7

Source: Internet
Author: User
Tags change settings mysql client uuid

I'm going to put a mysql5.7 on my centos7.2, I choose to compile the installation

1 To install, first have to install the package, download to

Because mysql5.7 requires boost, we recommend that you try to install the MySQL source package download with boost, so you don't have to bother installing boost alone. I downloaded mysql-boost-5.7.18.tar.gz.

[email protected] ~]# ll mysql-boost-5.7.18.tar.gz

-rw-r--r--. 1 root root 61612105 November 9 mysql-boost-5.7.18.tar.gz

2 Check the system has not installed MySQL and boost

[Email protected] ~]# Rpm-qa | grep boost

[Email protected] ~]# Rpm-qa | grep MySQL

3 Some dependent packages required to install MySQL

[[email protected] ~]# yum-y install make gcc-c++ cmake bison-devel ncurses-devel Bison perl perl-devel Perl Perl-deve L

........................... As dependencies are upgraded:

Libdb.x86_64 0:5.3.21-20.EL7

Libdb-utils.x86_64 0:5.3.21-20.EL7

Libstdc++.x86_64 0:4.8.5-16.EL7

Complete!

4 installed the dependency package, you can start to install our MySQL.

1) Create MySQL users and groups

For security reasons, MySQL users do not log in, and MySQL as a system service, specifies that the MySQL user's group is a MySQL group

[Email protected] ~]# groupadd mysql;useradd-r-G mysql-s/bin/false MySQL

The-R parameter of Useradd is to create the system account,-g specifies that the user belongs to the mysql,-s/bin/false specified user's shell is forbidden login, in fact, here can also be set to/sbin/nologin.

/bin/false is the most restrictive login option and all services are not available.

/sbin/nologin simply does not allow the login system.

When the user is configured to/sbin/nologin, if the user ssh to the Linux operating system, it will be prompted #this account was currently not available.

When the user is configured as/bin/false, the user cannot log in, there is no prompt after using SSH, the user does not switch over.

2) Create Data Catalog

[Email protected] ~]# mkdir-p/data/mysql/data

3) Unpack the package

[Email protected] ~]# TAR-ZXVF mysql-boost-5.7.18.tar.gz

.........................

4) Compiling

[Email protected] mysql-5.7.18]# Cmake-dcmake_install_prefix=/usr/local/mysql-ddefault_charset=utf8-ddefault_ Collation=utf8_general_ci-dwith_boost=boost;make;make Install

.......................

Hey, because I was using a slag to configure the virtual machine, compile to get me one hours.

After compiling the installation, let's start preparing for use

5) Initialization

Change the user and group of MySQL installation directory to MySQL

[Email protected] mysql-5.7.18]# Cd/usr/local/mysql

[Email protected] mysql]# pwd

/usr/local/mysql

[[email protected] mysql]# chown-r MySQL.

[[email protected] mysql]# chgrp-r MySQL.

[Email protected] mysql]#

Do the above, began to initialize, because the production environment, often ask to turn on the SSL function, I started here to initialize the

[Email protected] mysql]# bin/mysqld--initialize--user=mysql--basedir=/usr/local/mysql--datadir=/data/mysql/data

2017-11-10t11:41:27.358625z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. --explicit_defaults_for_timestamp server option (see documentation for more details).

2017-11-10t11:41:29.728684z 0 [Warning] innodb:new log files created, lsn=45790

2017-11-10t11:41:30.113932z 0 [Warning] innodb:creating FOREIGN KEY constraint system tables.

2017-11-10t11:41:30.796879z 0 [Warning] No existing UUID have been found, so we assume that's the first time that thi s server has been started. Generating a new uuid:18512606-c60c-11e7-b780-000c294e66bd.

2017-11-10t11:41:30.924616z 0 [Warning] Gtid table is not a ready-to-be used. Table ' mysql.gtid_executed ' cannot be opened.

2017-11-10t11:41:30.929250z 1 [Note] A temporary password is generated for [email protected]: gdqqgu8uer+a

6) Add MySQL to the system service

[email protected] mysql]# CP support-files/mysql.server/etc/init.d/mysqld

[Email protected] mysql]# chmod a+x/etc/init.d/mysqld

[Email protected] mysql]#

7) Replace the configuration file:

[Email protected] support-files]# Cp/etc/my.cnf/etc/my.cnf.bak

[email protected] support-files]# CP my-default.cnf/etc/my.cnf

MY.CNF My.cnf.bak my.cnf.d/

[email protected] support-files]# CP my-default.cnf/etc/my.cnf

CP: Do you want to overwrite "/etc/my.cnf"? Y

[Email protected] support-files]#

8) Give permission:

[Email protected] sys]# chown-r mysql.mysql/data/mysql/

[Email protected] sys]# chown-r mysql.mysql/var/run/mysql/

[Email protected] sys]# chown-r mysql.mysql/var/lib/mysql/

[Email protected] sys]# chown-r mysql.mysql/var/log/mysql/

[Email protected] sys]# chown-r mysql.mysql/data/mysql/

9) Start MySQL:

[[Email protected] sys]# service mysqld start

Starting mysql.logging to '/var/log/mysql/mysql.log '.

. success!

10) connect to MySQL:

[Email protected] bin]# mysql-u root-p

Enter Password:

ERROR 2002 (HY000): Can ' t connect to local MySQL server through socket '/tmp/mysql.sock ' (2)

This is because the host name parameter that we use to connect to the database is "localhost", or the hostname parameter is not used, and the server uses "localhost" as the hostname by default. Using the hostname parameter for "localhost" connection to the MySQL server, the MySQL client will be considered to be connected to the machine, so will try to connect as a socket file (socket file connection, more efficient than "IP: Port" mode), at this time according to the configuration file "/ Etc/mysql.cnf "path, this error is raised when the corresponding socket file is not found.

So the MySQL client needs to be able to find the Scoket file, this parameter is configured in the My.cnf file

[Email protected] bin]# VI/ETC/MY.CNF

# for advice The change settings

..............................................

[Client]

Socket =/var/lib/mysql/mysql.sock

[MySQL]

Socket =/var/lib/mysql/mysql.sock

After adding the configuration, restart MySQL

[Email protected] bin]# mysql-uroot-p

Enter Password:

.................................

Type ' help ', ' or ' \h ' for help. Type ' \c ' to clear the current input statement.

Mysql>

OK, my MySQL is ready.

Next time mysqldb for Python



PS: Personal opinion, if there is a wrong place, please correct me.

This article is from the "All-up" blog, be sure to keep this source http://zhenghong.blog.51cto.com/1676992/1980743

CENTOS7 installation mysql5.7

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.