溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊(cè)×
其他方式登錄
點(diǎn)擊 登錄注冊(cè) 即表示同意《億速云用戶服務(wù)條款》

安裝MySQL 教程詳解

發(fā)布時(shí)間:2020-04-28 11:50:03 來(lái)源:億速云 閱讀:254 作者:三月 欄目:數(shù)據(jù)庫(kù)

本文主要給大家介紹安裝MySQL 教程詳解,希望可以給大家補(bǔ)充和更新些知識(shí),如有其它問(wèn)題需要了解的可以持續(xù)在億速云行業(yè)資訊里面關(guān)注我的更新文章的。

 本次主要是mysql-5.5.54 的安裝

基礎(chǔ)環(huán)境為:

                  centos 6.8 

 一、下載mysql-5.5.54 安裝包

       創(chuàng)建軟件存放目錄

                    mkdir /home/softwares/

                    cd  /home/softwares/

                    wget  http://dev.mysql.com/get/Downloads/MySQL-5.5/mysql-5.5.54.tar.gz

二、安裝mysql 依賴包

                    yum install -y cmake;

                    yum install -y gcc gcc-c++ ;

                    yum install -y ncurses-devel.x86_64 ;

                    yum install -y cmake.x86_64 ;

                    yum install -y libaio.x86_64 ;

                    yum install -y bison.x86_64 ;

                    yum install -y gcc-c++.x86_64;

                    yum install -y perl-Module-Build;

                    yum install -y libtool zilib-devel ;

                    yum install -y libaio.x86_64;

                    yum install -y perl.x86_64;

                    yum install -y perl-Module-Pluggable.x86_64;

                    yum install -y perl-Pod-Escapes.x86_64;

                    yum install -y perl-Pod-Simple.x86_64;

                    yum install -y perl-libs.x86_64;

                    yum install -y perl-version.x86_64  ;

                    yum install –y openssl openssl-devel ncurses ncurses-devel;

            2、創(chuàng)建用戶和組分區(qū)

                   groupadd mysql  

                   useradd mysql -g mysql -M -s /sbin/nologin

            3、解壓mysql-5.5.54.tar.gz

                   tar -zxvf mysql-5.5.54.tar.gz && cd mysql-5.5.54/  && chmod +x *

            4、編譯安裝

安裝MySQL 教程詳解

cmake \ ##相當(dāng)于config
-DCMAKE_INSTALL_PREFIX=/u01/app/mysql/db \   ##數(shù)據(jù)庫(kù)安裝的目錄
-DSYSCONFDIR=/u01/app/mysql/db/etc \       ##數(shù)據(jù)庫(kù)安裝的配置文件,不用原來(lái)的默認(rèn)文件可以避免多次升級(jí)的時(shí)候讀取錯(cuò)誤的配置文件
-DMYSQL_DATADIR=/u01/data/mysql/db/data \ ##數(shù)據(jù)庫(kù)默認(rèn)存放庫(kù)表存放的位置
-DWITH_MYISAM_STORAGE_ENGINE=1 \ 
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DWITH_MEMORY_STORAGE_ENGINE=1 \
-DWITH_PERFSCHEMA_STORAGE_ENGINE=1 \
-DWITH_BLACKHOLE_STORAGE_ENGINE=1 \
-DWITH_READLINE=1 \
-DMYSQL_UNIX_ADDR=/u01/app/mysql/db/mysql.sock \ ##本地通信日志
-DMYSQL_TCP_PORT=3306 \
-DENABLED_LOCAL_INFILE=1 \
-DWITH_PARTITION_STORAGE_ENGINE=1 \
-DEXTRA_CHARSETS=all \
-DDEFAULT_CHARSET=utf8 \
-DDEFAULT_COLLATION=utf8_general_ci \

             make  install

           5、編寫配置文件

                cd /u01/app/mysql/db/  &&  mkdir etc && cd etc

                mkdir etc

                vi my.cnf

cat my.cnf 

[mysqld]

#########data###########

user=mysql

basedir = /u01/app/mysql/db

datadir = /u01/app/mysql/data

innodb_log_group_home_dir=/u01/app/mysql/engine/innolog

innodb_log_file_size = 50M

innodb_data_home_dir=/u01/app/mysql/engine/innodata

#innodb_data_file_path = ibdata1:100M;ibdata2:150M:autoextend

innodb_data_file_path = ibdata1:100M:autoextend

log-bin = /u01/app/mysql/log/mysql-binlog

log-bin-index = /u01/app/mysql/log/mysql-bin.index

binlog_cache_size = 32M

max_binlog_size=512M

binlog_format=row

innodb_file_per_table=1

log-error = /u01/app/mysql/mysql-error.log

pid-file = /u01/app/mysql/mysql.pid

skip-name-resolve

socket=/u01/app/mysql/mysql.sock

############pool#########

#*******skip-innodb*********

innodb_additional_mem_pool_size = 64M

innodb_buffer_pool_size=256M

innodb_write_io_threads = 8

innodb_read_io_threads = 8

innodb_thread_concurrency = 16

innodb_flush_log_at_trx_commit = 1

innodb_log_buffer_size = 16M

innodb_log_file_size = 512M

innodb_log_files_in_group = 3

innodb_max_dirty_pages_pct = 90

innodb_lock_wait_timeout = 120

port=3306

server-id= 1

# *** global cache ***

read_buffer_size = 32M

read_rnd_buffer_size = 128M

sort_buffer_size = 64M

join_buffer_size = 64M

# *** query cache ***

query_cache_size = 128M

query_cache_limit = 4M

# *** bin log ***

#log_slave_updates

log_warnings

###########others#########

#***transaction***

default-storage-engine = INNODB

transaction_isolation = REPEATABLE-READ

# *** thread ***

thread_cache_size = 16

thread_stack = 512K

#*** network ***

back_log = 512

#skip-networking

max_connections = 3000

max_connect_errors = 30

table_open_cache = 4096

max_allowed_packet = 32M

max_heap_table_size = 512M

#*** char set ***

character-set-server = utf8

#explicit_defaults_for_timestamp = true

# *** tmp table ***

tmp_table_size = 128M

# *** slow query log ***

slow_query_log

long_query_time = 10

[mysqldump]

quick

max_allowed_packet = 32M

[mysql]

auto-rehash

[myisamchk]

key_buffer_size = 12M

sort_buffer_size = 12M

read_buffer = 32M

write_buffer = 32M

[mysqlhotcopy]

interactive-timeout

[client]

socket=/u01/app/mysql/mysql.sock

port=3306

           6、將mysql啟動(dòng)腳本腳本命令復(fù)制到/etc/init.d/

                cp /u01/app/mysql/db/support-files/mysql.server  /etc/init.d/mysqld && chmod +x                 /etc/init.d/mysqld

                chmod +x /etc/init.d/mysqld

               

           7、根據(jù)my.cnf 創(chuàng)建目錄他不會(huì)自動(dòng)創(chuàng)建目錄

               mkdir -p /u01/app/mysql/data/engine/innolog

               mkdir -p /u01/app/mysql/data/engine/innodata

               mkdir -p /u01/app/mysql/data/mysql-binlog

               mkdir -p /u01/app/mysql/log/

               chown mysql. /u01/app/mysql/ -R

                cd /u01/app/mysql/db

          8、初始化語(yǔ)句數(shù)據(jù)庫(kù)安裝指定的目錄,數(shù)據(jù)庫(kù)默認(rèn)存放目錄

               ./scripts/mysql_install_db --basedir=/u01/app/mysql/db --datadir=/u01/app/mysql/data --user=mysql

           更改環(huán)境變量

            vim ~/.bash_profile

            PATH=$PATH:$HOME/bin:/u01/app/mysql/db/bin/

            環(huán)境變量生效

             source ~/.bash_profile

            如果報(bào)錯(cuò):

 /etc/init.d/mysqld start

 配置文件的問(wèn)題

 Starting MySQL... ERROR! The server quit without updating PID file (/data/mysql/mysql.pid).

一般需要自己查詢配置文件是否設(shè)置的參數(shù)過(guò)大或者過(guò)小,查看機(jī)器內(nèi)存是否過(guò)小,如果都是可以的請(qǐng)刪除除了db 文件之外的所有 然后重新創(chuàng)建目錄

              ##########啟動(dòng)成功之后設(shè)置密碼###########

                mysqladmin -uroot password "123456"

看了以上關(guān)于安裝MySQL 教程詳解,希望能給大家在實(shí)際運(yùn)用中帶來(lái)一定的幫助。本文由于篇幅有限,難免會(huì)有不足和需要補(bǔ)充的地方,如有需要更加專業(yè)的解答,可在官網(wǎng)聯(lián)系我們的24小時(shí)售前售后,隨時(shí)幫您解答問(wèn)題的。


向AI問(wèn)一下細(xì)節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI