MySQL安裝篇

來源:互聯網
上載者:User

標籤:blog   http   ar   io   os   sp   for   on   檔案   

環境介紹
    系統:CentOS 5.8 64位

    MySQL版本:mysql-5.6.22-linux-glibc2.5-x86_64


注意:以二進位安裝。因為MySQL的編譯需要很長的時間。


安裝步驟
    1.安裝的前期準備工作。
        a.關閉selinux
            vim /etc/sysconfig/selinux
            SELINUX=DISABLED

        b.臨時關閉
            setenforce 0
        c.關閉防火牆
            service iptables stop

    其中方法a和方法b任選一個,但是方法a需要重啟伺服器才會生效。

    2.官網下載需要安裝MySQL的二進位包,下載的安裝包我放在/opt/software目錄下
    3.解壓縮安裝包
        a.mkdir /opt/mysql
        b.cd /opt/mysql
        c.tar -zxf /opt/software/mysql-5.6.22-linux-glibc2.5-x86_64.tar.gz
        d.cd /usr/local
        e.ln -s /opt/mysql/mysql-5.6.22-linux-glibc2.5-x86_64 mysql
    4.建立使用者組以及使用者
        a.groupadd mysql
        b.useradd -g mysql -d /data/mysql/mysql_3306 -s /sbin/nologin mysql
    5.建立設定檔
        a.cp /usr/local/mysql/support-files/my-default.cnf /etc/my.cnf
    6.初始化資料庫
        a.mkdir -p /data/mysql/mysql_3306
        b.chown -R mysql:mysql /data/mysql/ chown -R mysql:mysql /usr/local/mysql/
        c.cd /usr/local/mysql
        e. ./script/mysql_install_db -user=mysql --basedir=/usr/local/mysql --datadir=/data/mysql/mysql_3306
    7.添加環境變數
        a.echo "PATH=$PATH:/usr/local/mysql/bin">>/etc/profile
        b.source /etc/profile
    8.啟動
        a.cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld
        b./etc/init.d/mysqld start
安裝過程出現的錯誤:
    1.在啟動時報錯:

    這個時候查看MySQL的錯誤記錄檔如:


    出現這種問題解決辦法是:
        a.刪除/data/mysql/mysql_3306目錄下的所有檔案
        b.再次初始化資料庫
            ./mysql_install_db -user=mysql --basedir=/usr/local/mysql --datadir=/data/mysql/mysql_3306 --ldata=/data/mysql/mysql_3306/data

    當然初始化資料還有另外的一種方式./mysql_install_db -user=mysql --defautls-file=/etc/my.cnf。最後需要記住的是初始化資料庫一定要在basedir下進行。


我目前在安裝的時候就出現了這麼一個問題,要是還出現其他的問題可以留言交流,下邊是我的設定檔。

[[email protected] support-files]# cat /etc/my.cnf #my.cnf[client]port            = 3306socket          = /tmp/mysql.sock[mysql]prompt="\\[email protected]\\h:\p  \\R:\\m:\\s [\\d]>"#tee=/data/mysql/mysql_3306/data/query.logno-auto-rehash[mysqld_multi]mysqld = /usr/local/mysql/bin/mysqld_safemysqladmin = /usr/local/mysql/bin/mysqladminlog = /opt/mysql/mysqld_multi.log[mysqld]#miscuser = mysqlbasedir = /usr/local/mysqldatadir = /data/mysql/mysql_3306/dataport = 3306socket = /tmp/mysql.sockevent_scheduler = 0#timeoutinteractive_timeout = 300wait_timeout = 300#character setcharacter-set-server = utf8open_files_limit = 65535max_connections = 100max_connect_errors = 100000skip-name-resolve = 1#logslog-output=fileslow_query_log = 1slow_query_log_file = slow.loglog-error = error.loglog_warnings = 2pid-file = mysql.pidlong_query_time = 1#log-slow-admin-statements = 1#log-queries-not-using-indexes = 1log-slow-slave-statements = 1#binlogbinlog_format = mixedserver-id = 203306log-bin = mybinlogbinlog_cache_size = 4Mmax_binlog_size = 1Gmax_binlog_cache_size = 2Gsync_binlog = 0expire_logs_days = 10#relay logskip_slave_start = 1max_relay_log_size = 1Grelay_log_purge = 1relay_log_recovery = 1log_slave_updates#slave-skip-errors=1032,1053,1062explicit_defaults_for_timestamp=1#buffers & cachetable_open_cache = 2048table_definition_cache = 2048table_open_cache = 2048max_heap_table_size = 96Msort_buffer_size = 2Mjoin_buffer_size = 2Mthread_cache_size = 256query_cache_size = 0query_cache_type = 0query_cache_limit = 256Kquery_cache_min_res_unit = 512thread_stack = 192Ktmp_table_size = 96Mkey_buffer_size = 8Mread_buffer_size = 2Mread_rnd_buffer_size = 16Mbulk_insert_buffer_size = 32M#myisammyisam_sort_buffer_size = 128Mmyisam_max_sort_file_size = 10Gmyisam_repair_threads = 1#innodbinnodb_buffer_pool_size = 100Minnodb_buffer_pool_instances = 1innodb_data_file_path = ibdata1:1G:autoextendinnodb_flush_log_at_trx_commit = 2innodb_log_buffer_size = 64Minnodb_log_file_size = 500Minnodb_log_files_in_group = 3innodb_max_dirty_pages_pct = 50innodb_file_per_table = 1innodb_rollback_on_timeoutinnodb_status_file = 1innodb_io_capacity = 2000transaction_isolation = READ-COMMITTEDinnodb_flush_method = O_DIRECT#連接埠號碼為3306的執行個體特殊配置[mysqld3306]port =3306 server-id=203306#指定本執行個體相應版本的basedir和datadirbasedir= /usr/local/mysqldatadir = /data/mysql/mysql_3306/datasocket          = /tmp/mysql_3306.sock#重新設定這幾個選項,不與全域配置一樣,會直接覆蓋上面的全域設定innodb_buffer_pool_size = 100m#transaction_isolation = REPEATABLE-READ[mysqld3308]port=3308server-id=203308#binlog-do-db=db01basedir= /usr/local/mysqldatadir = /data/mysql/mysql_3308/datasocket          = /tmp/mysql_3308.sock#重新設定這幾個選項,不與全域配置一樣,會直接覆蓋上面的全域設定innodb_buffer_pool_size = 100minnodb_flush_log_at_trx_commit = 2sync_binlog = 0[mysqld3309]port=3309server-id=203309#binlog-do-db=db01basedir= /usr/local/mysqldatadir = /data/mysql/mysql_3309/datasocket          = /tmp/mysql_3309.sock#重新設定這幾個選項,不與全域配置一樣,會直接覆蓋上面的全域設定innodb_buffer_pool_size = 100minnodb_flush_log_at_trx_commit = 2sync_binlog = 0


MySQL安裝篇

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.