Linux 安装MySQL5.7.18

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Linux 安装MySQL5.7.18相关的知识,希望对你有一定的参考价值。

https://dev.mysql.com/downloads/mysql/
Linux-Generic

md5sum mysql-5.7.18-linux-glibc2.5-x86_64.tar.gz

Linux环境检查

1 关闭numa

[[email protected] ~]#  vim /boot/grub/grub.conf
title Red Hat Enterprise Linux (2.6.32-358.el6.x86_64)
        root (hd0,0)
        kernel /vmlinuz-2.6.32-358.el6.x86_64 ro root=UUID=cb7d8bdc-28a5-4dbd-b04a-3ad9ee3e6bba rd_NO_LUKS rd_NO_LVM LANG=en_US.UTF-8 rd_NO_MD SYSFONT=latarcyrheb-sun16 crashkernel=auto  KEYBOARDTYPE=pc KEYTABLE=us rd_NO_DM rhgb quiet numa=off

[[email protected] ~]# numactl --hardware

[[email protected] ~]#numactl --show

2限制设置 /etc/security/limits.conf
[[email protected] ~]# vim /etc/security/limits.conf
* soft    nofile  1024000
* hard    nofile  1024000
* soft    nproc   unlimited
* hard    nproc   unlimited
* soft    core    unlimited
* hard    core    unlimited
* soft    memlock unlimited
* hard    memlock unlimited

3 Swap
[[email protected] ~]# vim /etc/sysctl.conf
vm.swappiness=0

sysctl -p 生效
[[email protected] ~]# sysctl -a|grep swap
vm.swappiness = 0

6 selinux & iptables

selinux:
[[email protected] ~]# vim /etc/sysconfig/selinux
SELINUX=disabled
SELINUXTYPE=targeted

[[email protected] ~]# getenforce
Disabled

setenforce 0
getenforce

chkconfig --list|grep iptables
chkconfig --del iptables

[[email protected] ~]# chkconfig --list|grep iptables
iptables        0:off 1:off 2:off 3:off 4:off 5:off 6:off

[[email protected] ~]# chkconfig --del iptables
[[email protected] ~]# chkconfig --list|grep iptables

[[email protected] ~]# reboot

1创建账户
[[email protected] home]# groupadd mysql
[[email protected] home]# useradd -g mysql -d /user/local/mysql -s /sbin/nologin -M mysql
[[email protected] home]# id mysql
uid=505(mysql) gid=506(mysql) groups=506(mysql)

[[email protected] home]# mkdir /opt/mysql
[[email protected] mysql]# tar xvf mysql-5.7.18-linux-glibc2.5-x86_64.tar.gz

[[email protected] ~]# cd /usr/local/
cd /user/local/
[[email protected] local]# ln -s /opt/mysql/mysql-5.7.18-linux-glibc2.5-x86_64 mysql

[[email protected] local]# chown -R mysql:mysql mysql/

[[email protected] mysql]# echo "export PATH=$PATH:/usr/local/mysql/bin">>/etc/profile
[[email protected] mysql]# source /etc/profile

/data 是一个单独挂载的分区

[[email protected] mysql]# mkdir -p /data/mysql/mysql_3306/{data,logs,tmp}

[[email protected] mysql_3306]# chown -R mysql:mysql /data/mysql/mysql_3306/

[[email protected] ~]# cp /opt/my.cnf /etc/

初始化

[[email protected] mysql]# ./bin/mysqld  --defaults-file=/etc/mysql3306.cnf --initialize
[[email protected] mysql]# cat /data/mysql/mysql_3306/data/error.log |grep password
2017-04-28T06:36:55.453219Z 1 [Note] A temporary password is generated for [email protected]: rFcPw<f;k4+1

启动

[[email protected] mysql]# cp support-files/mysql.server /etc/init.d/mysql
[[email protected] mysql]# /etc/init.d/mysql start
Starting MySQL...................... SUCCESS!
cp support-files/mysql.server /etc/init.d/mysql

or

[[email protected] ~]# /usr/local/mysql/bin/mysqld --defaults-file=/etc/my.cnf &
[1] 2787

[[email protected] tmp]# mysql -S /tmp/mysql.sock -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 3
Server version: 5.7.18-log

Copyright (c) 2000, 2017, 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.

"(unknown)@localhost:mysql.sock  [(none)]>alter user user() identified by ‘123456‘;
Query OK, 0 rows affected (0.01 sec)

"[email protected]:mysql.sock  [(none)]>show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| sys                |
+--------------------+
4 rows in set (0.09 sec)

"[email protected]:mysql.sock  [(none)]>exit
Bye
[[email protected] etc]# mysqladmin -S /tmp/mysql.sock -p shutdown
Enter password:

 























































以上是关于Linux 安装MySQL5.7.18的主要内容,如果未能解决你的问题,请参考以下文章

Linux MySQL5.7.18自动化安装脚本

Linux MySQL5.7.18自动化安装脚本1

Linux系统下安装Mysql5.7.18教程收集分享

mysql5.7.18的安装与主从复制

Linux下MySQL5.7.18二进制包安装(无默认配置文件my_default.cnf)

Centos7 下Mysql5.7.18的安装和简单主从