Linux 安裝MySQL5.7.18

來源:互聯網
上載者:User

標籤:moni   glibc   tps   inux   current   sel   isa   data   end   

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

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.