Linux installation 64-bit Mysql5.7.22

Source: Internet
Author: User

transfer from https://www.cnblogs.com/jxrichar/p/9248480.html

To install in the/usr/local directory as an example

1. Download the installation package address: https://dev.mysql.com/downloads/file/?id=476936, save the installation package to/usr/local

2. Unzip:

Cd/usr/local

TAR-ZXVF Mysql-5.7.22-linux-glibc2.12-x86_64.tar

MV Mysql-5.7.22-linux-glibc2.12-x86_64 mysql-5.7.22

3. Add user groups and users

#添加用户组
Groupadd MySQL
#添加用户mysql to the user group MySQL
useradd-g MySQL MySQL

4. Installation

cd/usr/local/mysql-5.7.22

mkdir data

Chown-r Mysql:mysql./

./bin/mysqld–-initialize--user=mysql--basedir=/usr/local/mysql-5.7.22/--datadir=/usr/local/mysql-5.7.22/data/

#将mysql/directory Except for all files in the data/directory, change back to root user
Chown-r Root.
#mysql用户只需作为mysql the owner of all files in the -5.7.20/data/directory
Chown-r MySQL Data

5. Copy the boot file

CP Support-files/mysql.server/etc/init.d/mysqld

chmod 755/etc/init.d/mysqld

cp/bin/my_print_defaults/usr/bin/

6. Modify the startup script

Vi/etc/init.d/mysqld
#修改项:
basedir=/usr/local/mysql-5.7.20/
Datadir=/usr/local/mysql-5.7.20/data
port=3306

#加入环境变量, edit the/etc/profile so that you can use MySQL command from anywhere.
Vi/etc/profile
#添加mysql路径, add the following and press ESC-->:WQ to save
Export path= $PATH:/usr/local/mysql-5.7.20/bin
#刷新立即生效
Source/etc/profile

7. Modify MySQL Configuration items

Vi/etc/my.cnf

The configuration is as follows:

[Mysqld]
Basedir =/usr/local/mysql-5.7.22
DataDir =/usr/local/mysql-5.7.22/data
Socket =/tmp/mysql.sock
user = MySQL
Tmpdir =/tmp
Symbolic-links=0

[Mysqld_safe]

Log-error =/usr/local/mysql-5.7.22/data/error.log
Pid-file =/usr/local/mysql-5.7.22/data/mysql.pid
!includedir/etc/my.cnf.d

8. Start MySQL

Service mysqld Start

If startup fails, delete all files under/usr/local/mysql-5.7.22/data and re-execute./bin/mysqld–-initialize--user=mysql--basedir=/usr/local/ mysql-5.7.22/--datadir=/usr/local/mysql-5.7.22/data/, start again.

9. Enter MySQL to modify the initial password, modify the remote connection user permissions issues

Mysql-uroot-p

ALTER User User () identified by ' 123 ';

Use MySQL;

Update user Set host = '% ' where user = ' root ';

Flush privileges;

Linux installation 64-bit Mysql5.7.22

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.