您好,登錄后才能下訂單哦!
本文主要給大家介紹linux CentOS 7 系統(tǒng)應(yīng)該如何安裝mysql 5.7.13,其所涉及的東西,從理論知識(shí)來獲悉,有很多書籍、文獻(xiàn)可供大家參考,從現(xiàn)實(shí)意義角度出發(fā),億速云累計(jì)多年的實(shí)踐經(jīng)驗(yàn)可分享給大家。
1.安裝環(huán)境:
[root@localhost ~]# cat /etc/redhat-release CentOS Linux release 7.3.1611 (Core)
Mysql版本號(hào):mysql-5.7.13-linux-glibc2.5-x86_64.tar
各項(xiàng)配置路徑:
安裝文件下載目錄:/data/software (軟件包所在位置)
Mysql目錄安裝位置:/usr/local/mysql
數(shù)據(jù)庫(kù)保存位置:/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
執(zhí)行如下命名:
# 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 總用量 0 drwxr-xr-x. 2 root root 6 11月 5 2016 bin drwxr-xr-x. 2 root root 6 11月 5 2016 etc drwxr-xr-x. 2 root root 6 11月 5 2016 games drwxr-xr-x. 2 root root 6 11月 5 2016 include drwxr-xr-x. 2 root root 6 11月 5 2016 lib drwxr-xr-x. 2 root root 6 11月 5 2016 lib64 drwxr-xr-x. 2 root root 6 11月 5 2016 libexec drwxr-xr-x. 9 7161 wheel 129 5月 25 2016 mysql-5.7.13-linux-glibc2.5-x86_64 drwxr-xr-x. 2 root root 6 11月 5 2016 sbin drwxr-xr-x. 5 root root 49 8月 23 00:39 share drwxr-xr-x. 2 root root 6 11月 5 2016 src # mkdir -p /data/mysql #創(chuàng)建數(shù)據(jù)倉(cāng)庫(kù)目錄 # groupadd mysql ---新建一個(gè)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/mysql datadir=/data/mysql
# vi /etc/my.cnf
修改為以下內(nèi)容:
[client] port = 3306 socket = /opt/mysql/mysql.sock #character_set_server=utf8 default-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_USER sql_mode='' #default-character-set=utf8 socket = /opt/mysql/mysql.sock basedir = /opt/mysql max_allowed_packet = 32M datadir = /data/mysql explicit_defaults_for_timestamp = true skip-ssl secure-file-priv = NULL lower_case_table_names = 1 back_log = 300 max_connections = 3000 max_connect_errors = 100 table_open_cache = 4096 external-locking = FALSE max_allowed_packet = 32M sort_buffer_size = 128M join_buffer_size = 128M explicit_defaults_for_timestamp = true thread_cache_size = 100 query_cache_size = 256M query_cache_limit = 4M ft_min_word_len = 8 thread_stack = 512k transaction_isolation = REPEATABLE-READ tmp_table_size = 128M max_heap_table_size = 128M #slow_query_log slow_query_log_file = /data/log/mysql/slow.log character-set-server=utf8 server_id =1 log-bin=mysqlbin-log long_query_time = 3 slow_query_log = on innodb_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重啟后自動(dòng)啟動(dòng)插件 plugin-load=AUDIT=libaudit_plugin.so #防止刪除了插件,重啟后又會(huì)加載 audit_record_cmds='delete,update,create,drop,alter,grant,truncate' #要記錄哪些命令語句,因?yàn)槟J(rèn)記錄所有操作; [mysqldump] quick max_allowed_packet = 32M [mysqld_safe] open-files-limit = 8192 log-error = /data/log/mysql/mysql_3306.err
以上為my.cnf中的內(nèi)容
# cd /usr/local/mysql # mkdir data # chown -R mysql . # chgrp -R mysql . # bin/mysqld_safe --user=mysql & (執(zhí)行后,ps –ef|grep mysql,可以看到mysql的進(jìn)程) # bin/mysqld_safe --skip-grant-tables --user=mysql & (后臺(tái)啟動(dòng)mysql,且忘記mysql密碼時(shí)使用) # bin/mysql --user=root -p
--輸入第6步生成的臨時(shí)密碼
修改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 root@'%' identified by 'redhat'; mysql> flush privileges; mysql> use mysql; mysql> select host,user from mysql.user;
# vi /etc/profile # 添加mysql系統(tǒng)路徑
添加:
export PATH=/usr/local/mysql/bin:$PATH
# source /etc/profile #導(dǎo)入配置 # chmod 755 /etc/init.d/mysql # 配置mysql自動(dòng)啟動(dòng) # chkconfig --add mysql #配置mysql自動(dòng)啟動(dòng) # chkconfig --level 345 mysql on #配置mysql自動(dòng)啟動(dòng)
登錄mysql:
# bin/mysql --user=root -p
至此mysql安裝完成。
總結(jié):
這種方式安裝的mysql,
# systemctl stauts/start/stop mysql.service
等操作不起作用。
但
#service mysql status/stop
可以運(yùn)行;
但是service mysql start 不能啟動(dòng),需要用:# bin/mysqld_safe --user=mysql & 才能啟動(dòng)
看了以上linux CentOS 7 系統(tǒng)應(yīng)該如何安裝mysql 5.7.13介紹,希望能給大家在實(shí)際運(yùn)用中帶來一定的幫助。本文由于篇幅有限,難免會(huì)有不足和需要補(bǔ)充的地方,大家可以繼續(xù)關(guān)注億速云行業(yè)資訊板塊,會(huì)定期給大家更新行業(yè)新聞和知識(shí),如有需要更加專業(yè)的解答,可在官網(wǎng)聯(lián)系我們的24小時(shí)售前售后,隨時(shí)幫您解答問題的。
免責(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)容。