亚洲激情专区-91九色丨porny丨老师-久久久久久久女国产乱让韩-国产精品午夜小视频观看

溫馨提示×

溫馨提示×

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

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務條款》

MySQL自動安裝腳本分享

發布時間:2021-09-01 17:40:03 來源:億速云 閱讀:314 作者:chen 欄目:MySQL數據庫

本篇內容介紹了“MySQL自動安裝腳本分享”的有關知識,在實際案例的操作過程中,不少人都會遇到這樣的困境,接下來就讓小編帶領大家學習一下如何處理這些情況吧!希望大家仔細閱讀,能夠學有所成!

環境要求:centos:6.8
                MySQL:5.7.20
                MySQL安裝文件名:mysql-5.7.20-linux-glibc2.12-x86_64.tar.gz
                MySQL源文件路徑:/usr/local/src
                MYSQL腳本文件:/usr/local/src/install_mysql.sh

1、腳本如下:

  1. #/bin/sh

  2. #px 2017-11-29

  3. #mysql install

  4. #email:kitten-pan@163.com & 752684428

  5. #version 2.0

  6. #mysql-version mysql5.7.20


  7. source_path=/usr/local/src

  8. install_path=/usr/local/mysql

  9. install_name=mysql-5.7.20-linux-glibc2.12-x86_64


  10. ##檢測本機環境

  11. env_fun()

  12. {

  13. echo "============檢測本機環境,please wait ..."

  14. username=`cat /etc/passwd |grep mysql|cut -c 1-5`

  15.     if [ "$username" = "mysql" ];then

  16.         echo "MySQL account is exits..."

  17.         return 10

  18.     else

  19.         echo "mysql account is not exits,ready add..."

  20.         groupadd mysql

  21.         useradd -r -s /sbin/nologin -g mysql mysql -d /usr/local/mysql

  22.         return 12

  23.     fi

  24. }


  25. ##判斷MySQL是否安裝

  26. check_fun()

  27. {

  28. rpm_name=`rpm -aq |grep mysql-server`

  29. echo $rpm_name

  30.     if [ ! $rpm_name ];then

  31.         echo "begin check the source install,please wait for a moment..."

  32.             if [ -d $install_path ];then

  33.                 echo "source install is exist,quit..."

  34.                 exit 0

  35.             else

  36.                 echo "本機未安裝MySQL,稍后為你安裝..."

  37.                 install_fun

  38.                 op_fun

  39.                 

  40.             fi

  41.     else

  42.         echo -n "rpm MySQL已經安裝,是否刪除?[yes|no]"

  43.         read select

  44.             if [ $select = yes ];then

  45.                 rpm -e $rpm_name --nodeps

  46.                 rm -rf /var/log/mysqld.log

  47.                 check_fun

  48.             else

  49.                 exit 0

  50.             fi

  51.     fi

  52. }


  53. ###安裝MySQL

  54. install_fun()

  55. {

  56. read  -p "Input a mysql version:" -t 30  mysql_version

  57. read  -p "Input a mysql port:" -t 30  mysql_port

  58. read  -p "Input a mysql_server_id:" -t 30 mysql_server_id

  59. cd $source_path && echo "解壓中,please waiting..."

  60. tar -zxvf ${install_name}.tar.gz && mv $install_name $install_path

  61. ##創建數據目錄

  62. mkdir -pv /data/mysqldata

  63. ###給MySQL目錄的MySQL賬號權限

  64. cd /usr/local && chown mysql.mysql mysql

  65. chown -R mysql.mysql /data/mysqldata

  66. cd $install_path && bin/mysqld --initialize --user=mysql --basedir=/usr/local/mysql --datadir=/data/mysqldata


  67. cd support-files && cp -rf mysql.server /etc/init.d/mysqld

  68. sed -i 's#datadir\=\/usr\/local\/mysql\/data#\datadir\=\/data\/mysqldata#g' /etc/init.d/mysqld


  69. cat > /etc/my.cnf << EOF

  70. [client]

  71. port = 3309

  72. socket = /tmp/mysql.sock

  73. default-character-set = utf8


  74. [mysqld]

  75. ##mysql-version=5.7.20

  76. port = 3309

  77. socket = /tmp/mysql.sock

  78. datadir = /data/mysqldata

  79. basedir = /usr/local/mysql

  80. pid-file = /data/mysqldata/mysqld.pid

  81. user = mysql

  82. server-id = 1

  83. lower_case_table_names = 1

  84. character-set-server = utf8

  85. back_log = 300

  86. max_connections = 1000

  87. max_connect_errors = 6000

  88. open_files_limit = 65535

  89. table_open_cache = 128

  90. max_allowed_packet = 4M

  91. binlog_cache_size = 1M

  92. max_heap_table_size = 8M

  93. tmp_table_size = 16M


  94. read_buffer_size = 2M

  95. read_rnd_buffer_size = 8M

  96. sort_buffer_size = 8M

  97. join_buffer_size = 8M

  98. key_buffer_size = 4M


  99. thread_cache_size = 8

  100. query_cache_type = 0

  101. query_cache_size = 2M

  102. query_cache_limit = 2M


  103. ft_min_word_len = 4


  104. log_bin = mysql-bin

  105. binlog_format = row

  106. expire_logs_days = 30


  107. log-error=/data/mysqldata/mysqld.log

  108. slow_query_log = 1

  109. long_query_time = 1

  110. slow_query_log_file = /data/mysqldata/mysql-slow.log


  111. performance_schema = 0

  112. explicit_defaults_for_timestamp


  113. skip-external-locking

  114. default-time_zone = '+8:00'


  115. default_storage_engine = InnoDB


  116. innodb_file_per_table = 1

  117. innodb_data_file_path = ibdata1:300M:autoextend

  118. innodb_open_files = 5000

  119. innodb_buffer_pool_size = 2048M

  120. innodb_write_io_threads = 4

  121. innodb_read_io_threads = 8

  122. innodb_thread_concurrency = 0

  123. innodb_purge_threads = 1

  124. innodb_flush_log_at_trx_commit = 2

  125. innodb_log_buffer_size = 128M

  126. innodb_log_file_size = 256M

  127. innodb_log_files_in_group = 2

  128. innodb_max_dirty_pages_pct = 90

  129. innodb_lock_wait_timeout = 120


  130. bulk_insert_buffer_size = 8M

  131. myisam_sort_buffer_size = 8M

  132. myisam_max_sort_file_size = 10G

  133. myisam_repair_threads = 1

  134. interactive_timeout = 28800

  135. wait_timeout = 300


  136. [mysqldump]

  137. quick

  138. max_allowed_packet = 16M


  139. [myisamchk]

  140. key_buffer_size = 8M

  141. sort_buffer_size = 8M

  142. read_buffer = 4M

  143. write_buffer = 4M


  144. EOF

  145. echo "export PATH=/$PATH:/usr/local/mysql/bin">>/etc/profile

  146. echo 'export MYSQL_PS1="(\u@\h:\p) [\d]>"' >> /etc/profile

  147. source /etc/profile


  148. service mysqld restart

  149. }


  150. op_fun()

  151. {

  152. chmod 755 /etc/init.d/mysqld

  153. chkconfig --add mysqld

  154. chkconfig --level 345 mysqld on

  155. }



  156. main(){

  157. echo "###==================================================###"

  158. echo "###welcome to make install mysql with this script###"

  159. echo "###copyright 2013 by px###"

  160. echo "###==================================================###"

  161. sleep 5

  162. env_fun

  163. re=$?

  164. if [ re = 10 ];then

  165.     check_fun

  166. else

  167.     check_fun

  168. fi

  169. }

  170. main

  171. exit 0

2、執行自動安裝腳本
    需要填寫MySQL的版本信息、端口信息、serverid信息等

點擊(此處)折疊或打開

  1. sh install_mysql.sh

  2. ###==================================================###

  3. ###welcome to make install mysql with this script###

  4. ###copyright 2013 by px###

  5. ###==================================================###

  6. ============檢測本機環境,please wait ...

  7. mysql account is not exits,ready add...


  8. begin check the source install,please wait for a moment...

  9. 本機未安裝MySQL,稍后為你安裝...

  10. Input a mysql version:5.7.20

  11. Input a mysql port:3309

  12. Input a mysql_server_id:1

  13. 解壓中,please waiting...

3、自動安裝完畢 啟動

# service mysqld  restart
MySQL server PID file could not be found!                  [FAILED]
Starting MySQL.............                                          [  OK  ]


4、登入MySQL 修改密碼

點擊(此處)折疊或打開

  1. [root@ct562 mysqldata]# mysql -uroot -p

  2. Enter password:

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

  4. Your MySQL connection id is 3

  5. Server version: 5.7.20-log


  6. Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.


  7. Oracle is a registered trademark of Oracle Corporation and/or its

  8. affiliates. Other names may be trademarks of their respective

  9. owners.


  10. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.


  11. (root@localhost:mysql.sock) [(none)]>

  12. (root@localhost:mysql.sock) [(none)]>

  13. (root@localhost:mysql.sock) [(none)]>

  14. (root@localhost:mysql.sock) [(none)]>

  15. (root@localhost:mysql.sock) [(none)]>

  16. (root@localhost:mysql.sock) [(none)]>set password for root@'localhost' =PASSWORD('sysdba@321')

“MySQL自動安裝腳本分享”的內容就介紹到這里了,感謝大家的閱讀。如果想了解更多行業相關的知識可以關注億速云網站,小編將為大家輸出更多高質量的實用文章!

向AI問一下細節

免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。

AI

汶川县| 吴忠市| 黄平县| 定安县| 孝感市| 报价| 鄢陵县| 黄山市| 财经| 武平县| 清涧县| 阜宁县| 汶川县| 德格县| 河东区| 和林格尔县| 云安县| 昭觉县| 安西县| 宜兰县| 临海市| 株洲县| 开阳县| 阳江市| 大竹县| 电白县| 石渠县| 隆子县| 黄冈市| 华宁县| 独山县| 万州区| 辽源市| 清原| 芜湖县| 塔城市| 桐城市| 台中县| 西昌市| 彭阳县| 克什克腾旗|