国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 學院 > 操作系統 > 正文

MySql配置、介紹

2024-06-28 16:04:07
字體:
來源:轉載
供稿:網友

MySQL配置文件

mysql配置文件位置:vim /etc/my.cnf 詳細配置文件的模塊(可作為模板直接復制)

# The MySQL server[mysqld]port = 3306socket = /tmp/mysql.sockskip-lockingkey_buffer_size = 256Mmax_allowed_packet = 1Mtable_open_cache = 256sort_buffer_size = 1Mread_buffer_size = 1Mread_rnd_buffer_size = 4Mmyisam_sort_buffer_size = 64Mthread_cache_size = 8query_cache_size= 16M# Try number of CPU's*2 for thread_concurrencythread_concurrency = 8

配置文件說明表:

項目 說明
port 監聽的端口;
socket 監聽的socket位置;
skip-locking 過濾lock,有些情況會有鎖,為了考慮速度可以過濾掉鎖;
key_buffer_size 索引塊的緩沖區,和內存有關系,增加大小可以增加索引速度;
max_allowed_packet 允許最大包,和mysql的web管理工具 導入數據包有關;
table_open_cache 所有的線程打開表的數量;
sort_buffer_size 排序的 緩沖區大小;
read_buffer_size 讀取Mysql數據的緩沖區;
read_rnd_buffer_size 隨機讀數據的緩沖區;
myisam_sort_buffer_size myisam搜索引擎的排序緩存區大小 ,mysql 有兩個搜索引擎 還有一個是 innodb;
thread_cache_size 線程緩存, 和CPU核數有關系,按照CPU 核數大小設置;
query_cache_size 查詢的緩存大小,查詢結果緩存在內存中 下次查詢可以可以直接緩存中調用;
thread_concurrency 和CPU核數有關,最大并發線程數,正常值是CPU核數X2;

【相關擴展配置參數】

客戶端保持在線的時間:

mysql客戶端 無數據訪問的時候,會有一段時間保持在線;但mysql允許同時連接的客戶端數量是有限的;過多無數據訪問客戶端在線會占用資源,影響mysql性能;這里可以手動設置無數據訪問客戶端保持在線的時長,以發揮mysql的最大傳輸性能;單位為秒 主配置文件中增加以下參數:(這里wait timeout需要與interactive_timeou配合使用;) interactive_timeout=8 wait timeout=8 這里設置的是保持客戶端在線時長8秒;

log-bin 配置二進制日志 和server-id 可以自行查詢資料了解。

慢查詢訪問日志配置

long_query_time 設置多長時間記錄一次慢查詢日志,單位為秒;log_solw_queries 定義慢查詢日志位置;

long_query_time = 1log_solw_queries = /data/mysql/slow.log

MySql的root密碼重置

重置密碼

使用root賬戶登錄mysql【默認是沒有密碼的】

[root@CentOS-1 ~]# mysql -urootWelcome to the MySQL monitor. Commands end with ; or /g.Your MySQL connection id is 11Server version: 5.1.73-log MySQL Community Server (GPL)Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.Oracle is a registered trademark of Oracle Corporation and/or itsaffiliates. Other names may be trademarks of their respectiveowners.Type 'help;' or '/h' for help. Type '/c' to clear the current input statement.mysql>

創建root密碼:

創建密碼:mysqladmin -uroot passWord 'chen1992'

使用root賬戶登錄mysql【-p后面跟密碼】:mysql -pchen1992

修改root的密碼:mysqladmin -uroot -pchen1992 password '1234qwer'

重置root密碼:(正常在忘記密碼的情況下使用)

編輯mysql配置文件:vim /etc/my.cnf

在配置文件中添加(不去授權)skip-grant

重啟mysql:/etc/init.d/mysqld restart

[root@CentOS-1 ~]# vim /etc/my.cnf[mysqld]···# Try number of CPU's*2 for thread_concurrencythread_concurrency = 8skip-grant···[root@CentOS-1 ~]# /etc/init.d/mysql restart

更新密碼:

mysql> use mysqlDatabase changedmysql> update user set password=password("1qaz2wsx") where user='root';mysql> select * from user where user='root'/G; 查看相關信息,可以查看加過密的密碼等

密碼更新后將vim /etc/my.cnf配置文件中的 skip-grant刪除,重啟mysql 即可

mysql登陸

本地登錄mysql:mysql -uroot -p1234qwer

遠程登錄mysql:mysql -uroot -h192.168.0.106 -P3306 -p1234qwer-u賬戶 -h地址 -P端口 -p密碼】

mysql中對指定ip授權:grant all on *.* to 'root'@'192.168.0.105' identified by '1234qwer';【這里的IP正常指的是客戶端IP】

查看是否授權成功的方法:

use mysql select * from user where host='192.168.0.106'/G;

mysql> select * from user where host='192.168.0.106'/G;*************************** 1. row *************************** Host: 192.168.0.106 //授權成功 User: root Password: *0CB5F227B3E98395CA0C6F1427427E77ADF49F89 Select_PRiv: Y Insert_priv: Y Update_priv: Y ···

查看當前mysql用戶:select user();

多個mysql 本地登錄方法:mysql -uroot -S /tmp/mysql.sock -p1234qwer


發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 定襄县| 卫辉市| 宝山区| 秭归县| 黄浦区| 汉源县| 宝应县| 宜兰市| 渑池县| 马边| 曲水县| 上高县| 玉溪市| 黔南| 谢通门县| 柳林县| 鄂伦春自治旗| 葫芦岛市| 通渭县| 鲁甸县| 南部县| 宁海县| 河间市| 南华县| 汤原县| 元阳县| 焉耆| 手游| 广宗县| 阜新| 灵寿县| 西畴县| 霍邱县| 观塘区| 海南省| 大埔县| 庆阳市| 斗六市| 三亚市| 友谊县| 固安县|