滲透測試基礎知識----MySQL 配置

雨筍教育發表於2022-03-17

MySQL 配置

1、建立mysql執行使用的使用者mysql

$ /usr/sbin/groupadd mysql$ /usr/sbin/useradd -g mysql mysql

2、建立binlog和庫的儲存路徑並賦予mysql使用者許可權

$ mkdir -p /usr/local/webserver/mysql/binlog /www/data_mysql$ chown mysql.mysql /usr/local/webserver/mysql/binlog/ /www/data_mysql/

3、建立my.cnf配置檔案

將/etc/my.cnf替換為下面內容

$ cat /etc/my.cnf[client]port = 3306socket = /tmp/mysql.sock[mysqld]replicate-ignore-db = mysqlreplicate-ignore-db = testreplicate-ignore-db = information_schemauser = mysqlport = 3306socket = /tmp/mysql.sockbasedir = /usr/local/webserver/mysqldatadir = /www/data_mysqllog-error = /usr/local/webserver/mysql/mysql_error.logpid-file = /usr/local/webserver/mysql/mysql.pidopen_files_limit = 65535back_log = 600max_connections = 5000max_connect_errors = 1000table_open_cache = 1024external-locking = FALSEmax_allowed_packet = 32Msort_buffer_size = 1Mjoin_buffer_size = 1Mthread_cache_size = 600#thread_concurrency = 8query_cache_size = 128Mquery_cache_limit = 2Mquery_cache_min_res_unit = 2kdefault-storage-engine = MyISAMdefault-tmp-storage-engine=MYISAMthread_stack = 192Ktransaction_isolation = READ-COMMITTEDtmp_table_size = 128Mmax_heap_table_size = 128Mlog-slave-updateslog-bin = /usr/local/webserver/mysql/binlog/binlogbinlog-do-db=oa_fbbinlog-ignore-db=mysqlbinlog_cache_size = 4Mbinlog_format = MIXEDmax_binlog_cache_size = 8Mmax_binlog_size = 1Grelay-log-index = /usr/local/webserver/mysql/relaylog/relaylogrelay-log-info-file = /usr/local/webserver/mysql/relaylog/relaylogrelay-log = /usr/local/webserver/mysql/relaylog/relaylogexpire_logs_days = 10key_buffer_size = 256Mread_buffer_size = 1Mread_rnd_buffer_size = 16Mbulk_insert_buffer_size = 64Mmyisam_sort_buffer_size = 128Mmyisam_max_sort_file_size = 10Gmyisam_repair_threads = 1myisam_recoverinteractive_timeout = 120wait_timeout = 120skip-name-resolve#master-connect-retry = 10slave-skip-errors = 1032,1062,126,1114,1146,1048,1396#master-host = 192.168.1.2#master-user = username#master-password = password#master-port = 3306server-id = 1loose-innodb-trx=0loose-innodb-locks=0loose-innodb-lock-waits=0loose-innodb-cmp=0loose-innodb-cmp-per-index=0loose-innodb-cmp-per-index-reset=0loose-innodb-cmp-reset=0loose-innodb-cmpmem=0loose-innodb-cmpmem-reset=0loose-innodb-buffer-page=0loose-innodb-buffer-page-lru=0loose-innodb-buffer-pool-stats=0loose-innodb-metrics=0loose-innodb-ft-default-stopword=0loose-innodb-ft-inserted=0loose-innodb-ft-deleted=0loose-innodb-ft-being-deleted=0loose-innodb-ft-config=0loose-innodb-ft-index-cache=0loose-innodb-ft-index-table=0loose-innodb-sys-tables=0loose-innodb-sys-tablestats=0loose-innodb-sys-indexes=0loose-innodb-sys-columns=0loose-innodb-sys-fields=0loose-innodb-sys-foreign=0loose-innodb-sys-foreign-cols=0slow_query_log_file=/usr/local/webserver/mysql/mysql_slow.loglong_query_time = 1[mysqldump]quickmax_allowed_packet = 32M

4、初始化資料庫

$/usr/local/webserver/mysql/scripts/mysql_install_db --defaults-file=/etc/my.cnf --user=mysql

5、建立開機啟動指令碼

$ cd /usr/local/webserver/mysql/$ cp support-files/mysql.server /etc/rc.d/init.d/mysqld$ chkconfig --add mysqld$ chkconfig --level 35 mysqld on

6、啟動mysql伺服器

更改許可權chown -R mysql.mysql /usr/local/webserver/mysql/啟動服務$ service mysqld start

滲透測試基礎知識----MySQL 配置

7、其他命令

啟動:service mysqld start停止:service mysqld stop重啟:service mysqld restart過載配置:service mysqld reload

8、連線Mysql

#預設空密碼/usr/local/webserver/mysql/bin/mysql -u root -p

滲透測試基礎知識----MySQL 配置

修改mysql密碼:

/usr/local/webserver/mysql/bin/mysqladmin -uroot -p password

或者進行mysql命令列修改:

SET PASSWORD FOR '使用者名稱'@'主機' = PASSWORD(‘密碼');

建立用並授權:

grant all privileges on *.* to 使用者名稱@'%' identified by '密碼' with grant option;

最後重新整理許可權:

flush privileges ;

*本文章僅供技術交流分享,請勿做未授權違法攻擊,雨筍教育不負任何責任。具體請參考《網路安全法》。


來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/70006652/viewspace-2871720/,如需轉載,請註明出處,否則將追究法律責任。

相關文章