Zhong__安装配置MySQL8.0
時間:2020.07.08
環境:Centos7.8
目的:安裝和配置MySQL8.0
說明:
作者:Zhong QQ交流群:121160124 歡迎加入!
?
下載MySQLYum Repository
Download the MySQL Yum Repository
wget https://repo.mysql.com//mysql80-community-release-el7-3.noarch.rpmAdding the MySQL Yum Repository
yum localinstall https://repo.mysql.com//mysql80-community-release-el7-3.noarch.rpm -y查看啟用的版本
yum repolist all | grep mysql yum repolist enabled | grep "mysql.*-community.*" yum repolist enabled | grep mysqlDisabling the Default MySQL Module (EL8 systems only)?
sudo yum module disable mysql安裝MySQL
Installing MySQL
sudo yum install mysql-community-server -yStarting the MySQL Server
sudo service mysqld start查看狀態
service mysqld status查看MySQL生成的臨時密碼
grep 'temporary password' /var/log/mysqld.log使用臨時密碼登錄
mysql -uroot -p修改root密碼
ALTER USER 'root'@'localhost' IDENTIFIED BY '123@CSDN.com'; #密碼要符合安全策略否則不生效修改完成之后新密碼生效后面使用新密碼登錄即可 臨時密碼將失效
創建普通用戶 配置遠程可連接
mysql -uroot -p? #登錄root賬戶 use mysql? #選擇mysql數據庫 create user zhong__ identified by 'abc@123';? #創建用戶zhong__? 密碼為abc@123 grant all on *.* to 'zhong__'@'%'; # 授權zhong__用戶所有數據庫的權限 可遠程連接 flush privileges;? #刷新權限使生效MySQL安全加固
禁用symbolic-links選項
描述
禁用符號鏈接以防止各種安全風險
檢查提示
--
加固建議
編輯Mysql配置文件/etc/my.cnf,在mysqld?段落中配置symbolic-links=0,5.6及以上版本應該配置為skip_symbolic_links=yes,并重啟mysql服務。
操作時建議做好記錄或備份
?
?
配置log-error選項
描述
啟用錯誤日志可以提高檢測針對mysql和其他關鍵消息的惡意嘗試的能力,例如,如果錯誤日志未啟用,則連接錯誤可能會被忽略。
檢查提示
--
加固建議
編輯Mysql配置文件/etc/my.cnf,在mysqld_safe?段落中配置log-error參數,<log_path>代表存放日志文件路徑,如:/var/log/mysqld.log,并重啟mysql服務:
log-error=<log_path>
操作時建議做好記錄或備份
?
?
修改默認3306端口
描述
避免使用熟知的端口,降低被初級掃描的風險
檢查提示
--
加固建議
編輯/etc/my.cnf文件,mysqld?段落中配置新的端口參數,并重啟mysql服務:
port=3506
操作時建議做好記錄或備份
?
?
刪除test數據庫
如果存在test數據庫
?
?
修改后的/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_passworddatadir=/var/lib/mysql socket=/var/lib/mysql/mysql.socklog-error=/var/log/mysqld.log pid-file=/var/run/mysqld/mysqld.pid# mysql security symbolic-links=0 skip_symbolic_links=yes port=3506[mysqld_safe] log-error=/var/log/mysqld.log重啟MySQL生效
service mysqld restart配置防火墻或云服務器安全組策略
開放端口使其可以遠程連接? ...
遠程連接和測試
使用數據庫工具或程序測試是否可連接? ...
完成安裝和配置 其它如有需要按需配置
?
?
Note
MySQL8.0版本和5.0版本其中一個比較明顯的區別就是數據庫默認字符集和排序規則不同? 在不同版本之間備份還原數據庫數據時要注意? 例如備份8.0版本數據庫數據如果字符集為utf8mb4? 還原到5.7版本如果手動建立的數據庫字符集為utf8的話? 大概率會報錯的? 可以在備份、還原數據前首先確認好字符集一致
?
?
?
?
總結
以上是生活随笔為你收集整理的Zhong__安装配置MySQL8.0的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 极客时间和极客学院_极客和书呆子之间的区
- 下一篇: SQL语句 - 嵌套查询(SQLServ