日日操夜夜添-日日操影院-日日草夜夜操-日日干干-精品一区二区三区波多野结衣-精品一区二区三区高清免费不卡

公告:魔扣目錄網為廣大站長提供免費收錄網站服務,提交前請做好本站友鏈:【 網站目錄:http://www.ylptlb.cn 】, 免友鏈快審服務(50元/站),

點擊這里在線咨詢客服
新站提交
  • 網站:51998
  • 待審:31
  • 小程序:12
  • 文章:1030137
  • 會員:747

操作系統環境:centos linux release 7.7.1908 (Core)

「原創」CentOS下MySQL8.0的超詳細的安裝及配置文檔

 

基礎環境配置

關閉SeLinux及防火墻

sed -i "s/SELINUX=enforcing/SELINUX=disabled/" /etc/selinux/config
setenforce 0 
?
systemctl stop firewalld    //停止系統默認的防火墻
systemctl mask firewalld    //屏蔽服務(讓它不能啟動)
yum remove -y firewalld     //卸載系統自帶的防火墻

安裝運維基礎工具

yum install -y chkconfig  net-tools ntsysv mlocate lrzsz wget lsof setuptool 

安裝yum源

yum install -y epel-release
wget https://dev.MySQL.com/get/mysql80-community-release-el7-2.noarch.rpm
yum localinstall -y mysql80-community-release-el7-2.noarch.rpm

MySQL8.0安裝

yum install -y bison-devel libaio-devel perl-Data-Dumper
yum install -y mysql-server
systemctl start mysqld     //啟動MySQL
systemctl enable mysqld.service  //開機自啟動

由于mysql的yum源是在國外,所以,在國內安裝很慢,因此,森哥的做法,是直接下載rpm包回來手工安裝 。如下操作:

wget https://dev.mysql.com/get/Downloads/MySQL-8.0/mysql-8.0.19-1.el7.x86_64.rpm-bundle.tar
tar -xvf mysql-8.0.19-1.el7.x86_64.rpm-bundle.tar
yum localinstall -y mysql-community-*     //使用localinstall會自己補足未安裝的所需要組件
systemctl start mysqld     //啟動MySQL
systemctl enable mysqld.service  //開機自啟動
「原創」CentOS下MySQL8.0的超詳細的安裝及配置文檔

 


「原創」CentOS下MySQL8.0的超詳細的安裝及配置文檔

 

修改初始密碼

grep 'temporary password' /var/log/mysqld.log     //mysql5.7版本后,初始密碼不再為空,默認隨機生成,可通過該命令查詢
mysql -u root -p   //進入mysql,輸入剛剛查到的密碼
alter user 'root'@'localhost' identified with mysql_native_password by '三種或以上的八位字符';        //修改密碼,并將密碼插件更改為mysql_native_password

初始my.cnf配置的內容為:

cat /etc/my.cnf
# For advice on how to change settings please see
# http://dev.mysql.com/doc/refman/8.0/en/server-configuration-defaults.html
?
[mysqld]
#
# Remove leading # and set to the amount of RAM for the most important data
# cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%.
# innodb_buffer_pool_size = 128M
#
# Remove the leading "# " to disable binary logging
# Binary logging captures changes between backups and is enabled by
# default. It's default setting is log_bin=binlog
# disable_log_bin
#
# Remove leading # to set options mainly useful for reporting servers.
# The server defaults are faster for transactions and fast SELECTs.
# Adjust sizes as needed, experiment to find the optimal values.
# join_buffer_size = 128M
# sort_buffer_size = 2M
# read_rnd_buffer_size = 2M
#
# Remove leading # to revert to previous value for default_authentication_plugin,
# this will increase compatibility with older clients. For background, see:
# https://dev.mysql.com/doc/refman/8.0/en/server-system-variables.html#sysvar_default_authentication_plugin
# default-authentication-plugin=mysql_native_password
?
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
?
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid

原則上,上面的這個配置,就可以正常使用了。但有時候為了一些業務場合的應用,就需要考慮對其進行修改,以達到符合實現業務的需求。

mkdir /var/log/mysqld
touch /var/log/mysqld/error.log
chown mysql.mysql /var/log/mysqld -R
# For advice on how to change settings please see
# http://dev.mysql.com/doc/refman/8.0/en/server-configuration-defaults.html

[mysqld]
#
# Remove leading # and set to the amount of RAM for the most important data
# cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%.
# innodb_buffer_pool_size = 128M
#
# Remove the leading "# " to disable binary logging
# Binary logging captures changes between backups and is enabled by
# default. It's default setting is log_bin=binlog
# disable_log_bin
#
# Remove leading # to set options mainly useful for reporting servers.
# The server defaults are faster for transactions and fast SELECTs.
# Adjust sizes as needed, experiment to find the optimal values.
# join_buffer_size = 128M
# sort_buffer_size = 2M
# read_rnd_buffer_size = 2M
#
# Remove leading # to revert to previous value for default_authentication_plugin,
# this will increase compatibility with older clients. For background, see:
# https://dev.mysql.com/doc/refman/8.0/en/server-system-variables.html#sysvar_default_authentication_plugin
# default-authentication-plugin=mysql_native_password

# server-id = 1    //單MySQL服務下,可以省略不用

datadir=/var/lib/mysql        //數據文件所在位置
socket=/var/lib/mysql/mysql.sock     //sock文件所在位置
log_error = /var/log/mysqld/error.log       //數據庫錯誤日志文件

# skip_name_resolve = 1         //設置這個,說明只能通過IP連接,不用主機名,一般不建議使用

character-set-server=utf8mb4         //數據庫默認字符集,可以支持表情符號等,utf8不支持表情符號。另外utf8mb4是mysql8.0起支持的。
collation-server = utf8mb4_general_ci    //數據庫字符集對應一些排序等規則,必須和character-set-server對應
transaction_isolation = READ-COMMITTED     //事務隔離級別,默認為可重復讀
init_connect='SET NAMES utf8mb4'           //設置client連接mysql時的字符集,防止亂碼
max_connections=500                       //最大連接數
max_connect_errors = 1000                  //最大錯誤連接數
explicit_defaults_for_timestamp = true       //TIMESTAMP如果沒有顯示聲明NOT NULL,允許NULL值
max_allowed_packet = 1024M                     //SQL數據包發送的大小,如果有BLOB對象建議修改成1G

# interactive_timeout = 1800               //MySQL默認的wait_timeout  值為8個小時, interactive_timeout參數需要同時配置才能生效
# wait_timeout = 1800

tmp_table_size = 134217728                //內部內存臨時表的最大值,超過了這個值將寫入磁盤,系統IO壓力增大
max_heap_table_size = 134217728

# query_cache_size = 0                   //禁用mysql的緩存查詢結果集功能,可根據業務需求是否開啟,通常為關閉
# query_cache_type = 0

# slow_query_log = 1                                   //慢查詢sql日志設置
# slow_query_log_file = /var/log/mysqld/slow.log
# long_query_time = 8                                 //慢查詢執行的秒數,必須達到此值可被記錄
# log_queries_not_using_indexes = 1                   //檢查未使用到索引的sql
# log_throttle_queries_not_using_indexes = 5         //開啟后,記錄慢sql的頻次、每分鐘記錄的條數
# min_examined_row_limit = 100                         // 檢索的行數必須達到此值才可被記為慢查詢

# skip-log-bin                                    //關閉binlog功能
binlog_expire_logs_seconds=604800                              //binlog日志文件保存的過期時間,過期后自動刪除
innodb_log_file_size=60M
innodb_buffer_pool_size=128M

[client]
default-character-set=utf8mb8
socket=/var/lib/mysql/mysql.sock

[mysqld_safe]
open-files-limit = 8192
log-error=/var/log/mysqld.log
socket=/var/lib/mysql/mysql.sock
pid-file=/var/run/mysqld/mysqld.pid

密碼恢復

有時候,會將root密碼給忘記了,就需要對MySQL進行密碼恢復。

在/etc/my.cnf中,的[mysqld]內,加入如下內容:

skip-grant-table             //改為安全模式,無法密碼登陸

重啟mysqld

systemctl restart mysqld

進入重置密碼

mysql -u root -p             //空密碼,直接回車
use mysql;
update user set authentication_string='' where user='root';   //先清空密碼

注釋掉my.cnf中的skip-grant-table,再重啟mysqld。然后就可以免密碼進入,再修改密碼。

mysql -u root -p   //不用輸入密碼,直接進入
alter user 'root'@'localhost' identified with mysql_native_password by '三種或以上的八位字符';        //修改密碼,并將密碼插件更改為mysql_native_password

現在就恢復正常使用了。

分享到:
標簽:MySQL8
用戶無頭像

網友整理

注冊時間:

網站:5 個   小程序:0 個  文章:12 篇

  • 51998

    網站

  • 12

    小程序

  • 1030137

    文章

  • 747

    會員

趕快注冊賬號,推廣您的網站吧!
最新入駐小程序

數獨大挑戰2018-06-03

數獨一種數學游戲,玩家需要根據9

答題星2018-06-03

您可以通過答題星輕松地創建試卷

全階人生考試2018-06-03

各種考試題,題庫,初中,高中,大學四六

運動步數有氧達人2018-06-03

記錄運動步數,積累氧氣值。還可偷

每日養生app2018-06-03

每日養生,天天健康

體育訓練成績評定2018-06-03

通用課目體育訓練成績評定