RedHat 6.7 Installing MySQL 5.7.18

Source: Internet
Author: User
Tags chmod deprecated uuid ssl connection

Environment Preparation:

Operating system: RedHat 6.7

Database: Mysql 5.7.18


1. Download mysql-5.7.18-linux-glibc2.5-x86_64.tar.gz from official website

Website address: http://dev.mysql.com/downloads/mysql/


2. Create a MySQL user group/user, the data directory and its user directory

Mkdir/home/mysql

Mkdir/mysql_data

GROUPADD-G 505 MySQL

Useradd-u 506-g mysql -s/bin/false-d/home/mysql MySQL


3. Unzip the installation package and copy the contents of the unpacking package to the MySQL installation directory/home/mysql

TAR-XVF mysql-5.7.18-linux-glibc2.5-x86_64.tar.gz-c/home/mysql/

Cd/home/mysql

MV Mysql-5.7.18-linux-glibc2.5-x86_64 MySQL

CD MySQL

MV *.. /

Chown Mysql:mysql-r/home/mysql

Chown Mysql:mysql-r/mysql_data

chmod 750-r/home/mysql

chmod 750-r/home/mysql_data



4. Initializing the database

Vim Mysql.server

Modify the Basedir and DataDir in the startup script to the directory we specified.

Basedir=/home/mysql

Datadir=/mysql_data


[Email protected] mysql]#/bin/mysqld--user=mysql--basedir=/home/mysql--datadir=/mysql_data--initialize

2017-04-26t02:17:42.485369z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. --explicit_defaults_for_timestamp server option (see documentation for more details).

2017-04-26t02:17:43.083466z 0 [Warning] innodb:new log files created, lsn=45790

2017-04-26t02:17:43.236539z 0 [Warning] innodb:creating FOREIGN KEY constraint system tables.

2017-04-26t02:17:43.357511z 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:87cd07e3-2a26-11e7-afe5-0800275a2175.

2017-04-26T02:17:43.385762Z 0 [Warning] Gtid table is not a ready-to-be used. Table ' mysql.gtid_executed ' cannot be opened.

2017-04-26t02:17:43.387836z 1 [Note] A temporary password is generated for [email protected]: 9NUZJVE>FSZB


After using mysqld--initialize, if the datadir point to the target directory already has the data file, the warning error will appear as follows:

After the delete is emptied, it can be re-initialized.

2017-04-24t08:51:45.724122z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. --explicit_defaults_for_timestamp server option (see documentation for more details).

2017-04-24t08:51:45.727068z 0 [ERROR]--initialize specified but the data directory have files in it. Aborting.

2017-04-24t08:51:45.727113z 0 [ERROR] aborting


5. Detect if the MySQL service can be started

# Cd/home/mysql/support-files

[[email protected] support-files]#./mysql.server start

Starting mysql.logging to '/mysql_data/iccsdb02.err '.

Determine


If the following error occurs:

Starting mysql.2017-04-25t03:03:32.124076z mysqld_safe Directory '/var/lib/mysql ' for UNIX socket file don ' t exists.

The server quit without updating PID file (/var/lib/mysql/i[failed]1.pid).

Check the/etc/my.cnf file to see if the DataDir is correct, by default there is no such profile, and we may need to add it manually later.



6. Create a soft link

Ln-s/home/mysql/bin/mysql/usr/bin/mysql

Ln-s/home/mysql/bin/mysqladmin/usr/bin/mysqladmin


7. Configure the MySQL service to boot automatically

Copy boot file to/etc/init.d/and command to Mysqld

# Cp/home/mysql/support-files/mysql.server/etc/init.d/mysqld


Increase execution permissions

# chmod 755/etc/init.d/mysqld


Check the list of self-initiated items without mysqld this, and if not, add Mysqld:

# chkconfig--list mysqld

# chkconfig--add mysqld


Set MySQL to automatically start at 345 level

# chkconfig--level mysqld on


8. mysql service start/restart/stop, in fact, the MySQL should have been able to start the normal


Start the MySQL service

# service Mysqld Start


Stop MySQL Service

# Service Mysqld Stop


Restart MySQL Service

# Service Mysqld Restart


9. Create a configuration file

Will default MY.CNF backup, if any

# Mv/etc/my.cnf/etc/my.cnf.bak


Access to MySQL installation directory support file directory


# Cd/home/mysql/support-files

# CP MY-DEFAULT.CNF/ETC/MY.CNF This step does not see the corresponding MY-DEFAULT.CNF file in this version of the software

You can modify the new profile options as needed, without modifying the configuration options, and MySQL runs on the default configuration parameters.


The default/etc/my.cnf is not, you can create a self can also download one from the Internet, here set code for UTF8 to prevent garbled, I test the configuration file as follows:


[Mysqld]

Datadir=/my_data

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

User=mysql

# Disabling Symbolic-links is recommended to prevent assorted security risks

Symbolic-links=0


Character_set_server=utf8

init_connect= ' SET NAMES UTF8 '


[Mysqld_safe]

Log-error=/var/log/mysqld.log

Pid-file=/var/run/mysqld/mysqld.pid


[Client]

Default-character-set=utf8


10. Initialize the password of the MySQL user root, there are many ways to say on the internet, but after testing how to use, so directly follow this to


Modify the MySQL configuration file (default is/ETC/MY.CNF) and add a line under [Mysqld] Skip-grant-tables


After service mysqld Restart, you can enter it directly with MySQL

[[email protected] run]# MySQL

Welcome to the MySQL Monitor. Commands End With; or \g.

Your MySQL Connection ID is 3

Server version:5.7.18 MySQL Community Server (GPL)


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


Oracle is a registered trademark of the Oracle Corporation and/or its

Affiliates. Other names trademarks of their respective

Owners.


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


Mysql>

mysql> Update Mysql.user Set Authentication_string=password (' 1q2w3e ') where user= ' root ' and Host = ' localhost ';

Query OK, 1 row affected, 1 warning (0.12 sec)

Rows matched:1 changed:1 warnings:1

mysql> flush Privileges;

Query OK, 0 rows affected (0.03 sec)

Mysql> quit


Re-entry will also prompt you to change the password

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

Enter Password:

Welcome to the MySQL Monitor. Commands End With; or \g.

Your MySQL Connection ID is 4

Server version:5.7.18


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


Oracle is a registered trademark of the Oracle Corporation and/or its

Affiliates. Other names trademarks of their respective

Owners.


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


mysql> show databases;

ERROR 1820 (HY000): Must reset your password using ALTER USER statement before executing this statement.

Mysql>


Re-update your password

[Email protected] mysql]# mysqladmin-u root-p Password

Enter Password:

New Password:

Confirm New Password:

Warning:since password is sent to server in plain text, use SSL connection to ensure password safety.

[Email protected] mysql]#


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

Enter Password:

Welcome to the MySQL Monitor. Commands End With; or \g.

Your MySQL Connection ID is 7

Server version:5.7.18 MySQL Community Server (GPL)


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


Oracle is a registered trademark of the Oracle Corporation and/or its

Affiliates. Other names 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>


Well, to this MySQL 5.7.18 has been installed successfully and local access to use the

This article is from the "record a bit of learning life" blog, please make sure to keep this source http://baishao.blog.51cto.com/2893832/1919678

RedHat 6.7 Installing MySQL 5.7.18

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.