Linux install MySQL 5.7

Source: Internet
Author: User

1. Download the installation package
http://dev.mysql.com/downloads/mysql/#downloads
It is recommended to download the TAR package (Http://cdn.mysql.com//Downloads/MySQL-5.7/mysql-5.7.12-linux-glibc2.5-x86_64.tar) for the common installation method.
2. Check if the library file exists and delete it.
[Email protected] desktop]$ Rpm-qa | grep MySQL
Mysql-libs-5.1.52-1.el6_0.1.x86_64[[email protected] ~]# rpm-e mysql-libs-5.1.52.x86_64--nodeps
[Email protected] ~]#
3. Check that the MySQL group and the user are present, if not created.
[Email protected] ~]# Cat/etc/group | grep MySQL
mysql:x:490:
[Email protected] ~]# CAT/ETC/PASSWD | grep MySQL
Mysql:x:496:490::/home/mysql:/bin/bash
These are the default conditions, such as none, to execute the Add command:
[[Email protected] ~] #groupadd MySQL
[[Email protected] ~] #useradd-R-G MySQL MySQL
The Useradd-r parameter indicates that the MySQL user is a system user and cannot be used to log on to the system.
4. Unzip the TAR package to change the group and user to which it belongs
[Email protected] ~]# cd/usr/local/
[Email protected] local]# tar xvf mysql-5.7.12-linux-glibc2.5-x86_64.tar
[Email protected] local]# ls-l
Total 1306432
-rwxr--r--. 1 root root 668866560 June 1 15:07 Mysql-5.7.12-linux-glibc2.5-x86_64.tar
-rw-r--r--. 1 7161 wheel 638960236 Mar 12:54 mysql-5.7.12-linux-glibc2.5-x86_64.tar.gz
-rw-r--r--. 1 7161 wheel 29903372 Mar 12:48 mysql-test-5.7.12-linux-glibc2.5-x86_64.tar.gz
[Email protected] local]# tar xvfz mysql-5.7.12-linux-glibc2.5-x86_64.tar.gz
[[Email protected] local]# mv mysql-5.7.12-linux-glibc2.5-x86_64 MySQL
[Email protected] local]# ls-l
Total 1306436
Drwxr-xr-x. 2 root root 4096 Dec 4 bin
Drwxr-xr-x. 2 root root 4096 Dec 4 etc
Drwxr-xr-x. 2 root root 4096 Dec 4 games
Drwxr-xr-x. 2 root root 4096 Dec 4 include
Drwxr-xr-x. 2 root root 4096 Dec 4 lib
Drwxr-xr-x. 3 root root 4096 Dec 2 14:36 lib64
Drwxr-xr-x. 2 root root 4096 Dec 4 libexec
Drwxr-xr-x. 9 7161 wheel 4096 Mar 12:51 MySQL
-rwxr--r--. 1 root root 668866560 June 1 15:07 Mysql-5.7.12-linux-glibc2.5-x86_64.tar
-rw-r--r--. 1 7161 wheel 638960236 Mar 12:54 mysql-5.7.12-linux-glibc2.5-x86_64.tar.gz
-rw-r--r--. 1 7161 wheel 29903372 Mar 12:48 mysql-test-5.7.12-linux-glibc2.5-x86_64.tar.gz
Drwxr-xr-x. 2 root root 4096 Dec 4 sbin
Drwxr-xr-x. 6 root root 4096 Dec 2 14:36 share
Drwxr-xr-x. 2 root root 4096 Dec 4 src
[Email protected] local]# chown-r MySQL mysql/
[Email protected] local]# chgrp-r MySQL mysql/

[Email protected] local]# CD mysql/

5.

mysql5.7 and previous versions, a lot of information is this command:. /scripts/mysql_install_db--user=mysql, while mysql5.7 's mysql_install_db command is in the bin directory and is recommended with the Mysqld--initialize command

mysql5.7 before version Initialization configuration Table command:

script/mysql_install_db--user=mysql--basedir=/ultrapower/test/mysql--datadir=/ultrapower/test/mysql/data/

--user the user who started the MySQL

--basedir MySQL installation directory

--datadir MySQL Data Warehouse directory

① Initialize table configuration correct execution steps: Bin/mysqld--initialize--user=mysql--basedir=/ultrapower/test/mysql--datadir=/ultrapower/test/ Mysql/data

② all files in the mysql/directory except the data/directory are changed back to the root user, and the MySQL user only needs to be the owner of all files in the mysql/data/directory.

    1. [Email protected] mysql]# chown-r root.
    2. [[email protected] mysql]# chown-r mysql data

③ Copying a configuration file

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

④mysql5.7 configuration files need to be modified MY.CNF critical configuration, mysql5.7 before the default configuration file is a configuration item, without manual modification

  [Mysqld]
    1. Basedir =/ultrapower/test/mysql
    2. DataDir =/ultrapower/test/mysql/data
    3. Port = 3306
    4. Socket =/ultrapower/test/mysql/tmp/mysql.sock
    5. Sql_mode=no_engine_substitution,strict_trans_tables

4. Add the Mysqld service to the boot entry.

Copy {mysql}/support-files/mysql.server to/etc/init.d/mysql and set run permissions so you can start/stop services using the service MySQL command.

Otherwise, you can use the {mysql}/bin/mysqld_safe & command to start the service

You also need to change the path of the Basedir in Mysql.server to the custom path, the default path is/usr/local/mysql

    1. #cp Mysql.server/etc/init.d/mysql
    2. #chmod +x/etc/init.d/mysql

Registering MySQL as a boot-start service

    1. #chkconfig--add MySQL

To see if a success was added
    1. [[email protected] mysql]# chkconfig--list MySQL
    2. Mysqld 0: Off 1: Off 2: Enable 3: Enable 4: Enable 5: Enable 6: Off
5.mysql Opening and closing of services
    1. #/etc/init.d/mysql start or serivce mysql start or bin/mysqld_safe&
    2. #/etc/init.d/mysql stop or service MySQL stop or bin/mysqladmin-uroot-p

Linux install MySQL 5.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.