日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問(wèn) 生活随笔!

生活随笔

當(dāng)前位置: 首頁(yè) > 运维知识 > 数据库 >内容正文

数据库

mysql binary安装_mysql的二进制安装方式

發(fā)布時(shí)間:2024/7/23 数据库 36 豆豆
生活随笔 收集整理的這篇文章主要介紹了 mysql binary安装_mysql的二进制安装方式 小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

mysql總共有三種安裝方式,源代碼安裝,二進(jìn)制安裝和源安裝。這次寫(xiě)的是二進(jìn)制安裝,對(duì)其他兩種方式不予討論。

關(guān)閉selinux和防火墻

上課的時(shí)候,老師說(shuō)過(guò)這是重中之重,一定要先關(guān)閉selinux和iptables。如果不關(guān)閉這兩個(gè),可能會(huì)出現(xiàn)莫名其妙的錯(cuò)誤,所以還是關(guān)閉的好。

[root@mysql_master mysql]# vi /etc/selinux/config

# This file controls the state of SELinux on the system.

# SELINUX= can take one of these three values:

# enforcing - SELinux security policy is enforced.

# permissive - SELinux prints warnings instead of enforcing.

# disabled - No SELinux policy is loaded.

SELINUX=disabled

# SELINUXTYPE= can take one of these two values:

# targeted - Targeted processes are protected,

# mls - Multi Level Security protection.

SELINUXTYPE=targeted

把SELINUX賦值為disabled就可以了,修改文件以后,是需要重啟的。再用getenforce來(lái)查看是否修改成功。

[root@mysql_master mysql]# getenforce

Disabled

先臨時(shí)關(guān)閉防火墻,再永久關(guān)閉防火墻

[root@mysql_master mysql]# service iptables stop

iptables: Setting chains to policy ACCEPT: filter [ OK ]

iptables: Flushing firewall rules: [ OK ]

iptables: Unloading modules: [ OK ]

[root@mysql_master mysql]# chkconfig iptables off

下載mysql二進(jìn)制安裝包

安裝mysql之前首先就要確定自己想要用什么分支什么版本的mysql了,這里我使用的mysql官方的5.6.29版本.這里還有別的選擇,例如percona分支和mariadb分支。好多人都推薦percona分支。

[root@mysql_master Downloads]# wget http://cdn.mysql.com//Downloads/MySQL-5.6/mysql-5.6.29-linux-glibc2.5-x86_64.tar.gz

下載完是這樣一個(gè)文件

[root@mysql_master Downloads]# ls

mysql-5.6.29-linux-glibc2.5-x86_64.tar.gz

創(chuàng)建用戶,組和data目錄

因?yàn)橹皇菫榱藢W(xué)習(xí)安裝。所以沒(méi)有創(chuàng)建其他的目錄,只是一個(gè)data目錄。創(chuàng)建mysql用戶并不是為了登錄主機(jī)的,而是單純?yōu)榱私o目錄和文件賦權(quán)限,表明這些是mysql用戶的,所以在創(chuàng)建用戶的使用使用了-r,-s /bin/false 來(lái)防止某些人使用這個(gè)用戶登錄主機(jī)。

[root@mysql_master]# groupadd mysql

[root@mysql_master]# useradd -r -g mysql -s /bin/false mysql

[root@mysql_master]# cd /

[root@mysql_master]# mkdir data

[root@mysql_master]# chown -R mysql:mysql /data

解壓mysql二進(jìn)制壓縮文件,并且初始化data目錄

解壓mysql二進(jìn)制壓縮文件到安裝目錄,我選擇/opt/mysql,你可以選擇其他的,還要先修改一個(gè)mysql配置文件,并且進(jìn)行簡(jiǎn)單的配置。解壓縮出來(lái)的目錄里面有這個(gè)文件的范本的。只需要拷貝和修改一下就可以了。我的配置范本在/opt/mysql/support-files下面,文件名為my-default.cnf,修改一下,并且cp到/etc/my.cnf

[root@mysql_master Downloads]# tar -zxvf mysql-5.6.29-linux-glibc2.5-x86_64.tar.gz

[root@mysql_master Downloads]# cp -a mysql-5.6.29-linux-glibc2.5-x86_64 /opt/mysql

[root@mysql_master Downloads]# cd /opt/mysql/support-files

[root@mysql_master support-files]# vi ./my-default.cnf /etc/my.cnf

把文件配置成為下面這樣就可以了,當(dāng)然這是最簡(jiǎn)單的配置,只是為了演示安裝而已。配置項(xiàng)為basedir,datadir,user三項(xiàng)。

# For advice on how to change settings please see

# *** DO NOT EDIT THIS FILE. It's a template which will be copied to the

# *** default location during install, and will be replaced if you

# *** upgrade to a newer version of MySQL.

[mysqld]

# Remove leading # and set to the amount of RAM for the most important data

# cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%.

# innodb_buffer_pool_size = 128M

# Remove leading # to turn on a very important data integrity option: logging

# changes to the binary log between backups.

# log_bin

# These are commonly set, remove the # and set as required.

basedir = /opt/mysql

datadir = /data

user = /data

# port = .....

# server_id = .....

# socket = .....

# Remove leading # to set options mainly useful for reporting servers.

# The server defaults are faster for transactions and fast SELECTs.

# Adjust sizes as needed, experiment to find the optimal values.

# join_buffer_size = 128M

# sort_buffer_size = 2M

# read_rnd_buffer_size = 2M

sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES

[root@mysql_master support-files]# cp my-default.cnf /etc/my.cnf

初始化/data目錄

[root@mysql_master mysql]# ./scripts/mysql_install_db --defaults-file = /etc/my.cnf

啟動(dòng)mysql,進(jìn)行連接測(cè)試

[root@mysql_master mysql]# ./bin/mysqld --defaults-file = /etc/my.cnf &

[root@mysql_master mysql]# ./bin/mysql -S /tmp/mysql.sock

Welcome to the MySQL monitor. Commands end with ; or \g.

Your MySQL connection id is 3

Server version: 5.6.29 MySQL Community Server (GPL)

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

mysql>

到這里,mysql的二進(jìn)制安裝就全部結(jié)束了。

總結(jié)

以上是生活随笔為你收集整理的mysql binary安装_mysql的二进制安装方式的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。

如果覺(jué)得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。