朝花夕拾:linux CentOS 7 安裝mysql 5.7.13

來源:互聯網
上載者:User

標籤:linux centos 7   安裝mysql 5.7   

1. 安裝環境:

[[email protected] ~]# cat /etc/redhat-releaseCentOS Linux release 7.3.1611 (Core)

Mysql版本號碼:mysql-5.7.13-linux-glibc2.5-x86_64.tar

各項配置路徑:
安裝檔案下載目錄:/data/software   (軟體包所在位置)
Mysql目錄安裝位置:/usr/local/mysql
資料庫儲存位置:/data/mysql
日誌儲存位置:/data/log/mysql

 2.本人百度雲端硬碟分享,下載mysql
    https://pan.baidu.com/s/1nuEypO9

 3.安裝主要步驟:

# rpm -qa |grep -i mariadb# rpm -e --nodeps mariadb-libs-5.5.52-1.el7.x86_64

執行如下命名:

# mkdir -p /data/software# mkdir -p /data/log/mysql # cd /data/software    #(上傳安裝包)

通過xftp或 rz命令 上傳mysql安裝包。

# cd /usr/local# tar -xvf /data/software/mysql-5.7.13-linux-glibc2.5-x86_64.tar.gz  # mv mysql-5.7.13-linux-glibc2.5-x86_64 mysql          # echo $?0# ll -h總用量 0drwxr-xr-x. 2 root root    6 11月  5 2016 bindrwxr-xr-x. 2 root root    6 11月  5 2016 etcdrwxr-xr-x. 2 root root    6 11月  5 2016 gamesdrwxr-xr-x. 2 root root    6 11月  5 2016 includedrwxr-xr-x. 2 root root    6 11月  5 2016 libdrwxr-xr-x. 2 root root    6 11月  5 2016 lib64drwxr-xr-x. 2 root root    6 11月  5 2016 libexecdrwxr-xr-x. 9 7161 wheel 129 5月  25 2016 mysql-5.7.13-linux-glibc2.5-x86_64drwxr-xr-x. 2 root root    6 11月  5 2016 sbindrwxr-xr-x. 5 root root   49 8月  23 00:39 sharedrwxr-xr-x. 2 root root    6 11月  5 2016 src# mkdir -p /data/mysql      #建立資料倉儲目錄# groupadd mysql    ---建立一個msyql組 # useradd -r -s    ---建立msyql使用者,禁止登入shell # cd /usr/local/mysql # chown -R mysql . # chgrp -R mysql .# chown -R mysql /data/mysql# cd /usr/local/mysql # bin/mysqld --initialize --user=mysql --basedir=/usr/local/mysql --datadir=/data/mysql #初始化mysql,記住初始mysql密碼# Touch mysql.error  # bin/mysql_ssl_rsa_setup  --datadir=/data/mysql# cd support-files/# cp my-default.cnf /etc/my.cnf # cp mysql.server /etc/init.d/mysql
# vi /etc/init.d/mysql

將空白的basedir和datadir修改為以下配置:

basedir=/usr/local/mysqldatadir=/data/mysql

# vi /etc/my.cnf
修改為以下內容:

[client]port = 3306socket = /opt/mysql/mysql.sock#character_set_server=utf8default-character-set=utf8[mysql]no-auto-rehash[mysqld]#sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USERsql_mode=''#default-character-set=utf8socket = /opt/mysql/mysql.sockbasedir = /opt/mysqlmax_allowed_packet = 32Mdatadir = /data/mysqlexplicit_defaults_for_timestamp = trueskip-sslsecure-file-priv = NULLlower_case_table_names = 1back_log = 300max_connections = 3000max_connect_errors = 100table_open_cache = 4096external-locking = FALSEmax_allowed_packet = 32Msort_buffer_size = 128Mjoin_buffer_size = 128Mexplicit_defaults_for_timestamp = truethread_cache_size = 100query_cache_size = 256Mquery_cache_limit = 4Mft_min_word_len = 8thread_stack = 512ktransaction_isolation = REPEATABLE-READtmp_table_size = 128Mmax_heap_table_size = 128M#slow_query_logslow_query_log_file = /data/log/mysql/slow.logcharacter-set-server=utf8server_id =1log-bin=mysqlbin-loglong_query_time = 3slow_query_log = oninnodb_buffer_pool_size = 1287M                       innodb_flush_log_at_trx_commit = 2                    innodb_log_buffer_size = 32M                             innodb_log_file_size = 512M  innodb_log_files_in_group = 2 innodb_max_dirty_pages_pct = 50 innodb_file_per_table = 1 binlog_format = ROW  audit_json_file=on    #保證mysql重啟後自動啟動外掛程式plugin-load=AUDIT=libaudit_plugin.so    #防止刪除了外掛程式,重啟後又會載入audit_record_cmds='delete,update,create,drop,alter,grant,truncate'   #要記錄哪些命令語句,因為預設記錄所有操作; [mysqldump]quickmax_allowed_packet = 32M[mysqld_safe]open-files-limit = 8192log-error = /data/log/mysql/mysql_3306.err


以上為my.cnf中的內容

# cd /usr/local/mysql# mkdir data# chown -R mysql .# chgrp -R mysql .# bin/mysqld_safe --user=mysql &         (執行後,ps –ef|grep mysql,可以看到mysql的進程)# bin/mysqld_safe  --skip-grant-tables --user=mysql &  (後台啟動mysql,且忘記mysql密碼時使用)# bin/mysql --user=root -p

--輸入第6步產生的臨時密碼

修改mysqlroot使用者密碼:

Mysql>set password for 'root'@'localhost' =password('redhat'); mysql>update mysql.user set authentication_string=password('redhat') where user='root';mysql>grant all privileges on *.* to [email protected]'%' identified by 'redhat'; mysql> flush privileges;mysql> use mysql; mysql> select host,user from mysql.user;
 # vi /etc/profile # 添加mysql系統路徑

添加:
export PATH=/usr/local/mysql/bin:$PATH

# source /etc/profile              #匯入配置# chmod 755 /etc/init.d/mysql   # 配置mysql自動啟動 # chkconfig --add mysql      #配置mysql自動啟動 # chkconfig --level 345 mysql on   #配置mysql自動啟動

登入mysql:

# bin/mysql --user=root -p

至此mysql安裝完成。

總結:

這種方式安裝的mysql,

# systemctl stauts/start/stop mysql.service


等操作不起作用。


#service mysql status/stop

可以運行;

但是service mysql start 不能啟動,需要用:# bin/mysqld_safe --user=mysql & 才能啟動

 

 


朝花夕拾:linux CentOS 7 安裝mysql 5.7.13

聯繫我們

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