mysql學習-----(2)

來源:互聯網
上載者:User

標籤:

---恢複內容開始---

0x01

mysql啟動時,讀取設定檔的順序   

Default options are read from the following files in the given order:
/etc/mysql/my.cnf     /etc/my.cnf      ~/.my.cnf

使用設定檔的方式
1.它依次尋找多個需要尋找的檔案,結果是所有檔案交集
2.如果某參數在多個檔案中宏出現多次,後配置的最終生效

可以使用 mysql --help --verbose 來查看
1.顯示mysql的程式啟動時可用的選項,通常都是長選項
2.顯示mysqld設定檔中可用的服務變數
mysql > show global variables
mysql > show session variables

 

0x02

1. 在mysql資料庫安裝好之後,首先的初始化操作就是刪除匿名使用者

查詢有哪些匿名使用者

select host,user,password from mysql.user;

刪除對應的匿名使用者,實際情況,可根據實際情況刪除。

drop user ‘‘@‘localhost‘;

drop user ‘‘@‘stuphp.hping3.com‘;

使用者名稱帳號由兩部分組成:[email protected]
host還可以使用萬用字元
%:任意長度的任一字元
_:匹配任意單個字

2. 給所有root使用者佈建密碼

第一種方式修改密碼:  

執行個體 ---> mysql > set password for [email protected] = password(‘photon‘); 

格式 ---> mysql > set password for [email protected] = password( ‘your_password‘)

第二種方式修改密碼:

該方式修改密碼,是直接修改mysql下的user表,所有要先進到user表中執行

故   use mysql;

update user set password = password(‘redhat‘) where user = ‘root‘;

讓其立即生效   ---- 即 讓其通知mysqld重新讀取 user表

flush privileges;

第三種方法修改密碼:

執行個體 ---->  

mysqladmin -uroot -hlocalhost password ‘photon‘ -p  ----localhost  是一個主機IP

mysqladmin -u root -h localhost -p flush-privileges    ----讓其生效

格式 ---->  

mysqladmin -u UserName -h Hot password ‘new_password‘ -p
mysqladmin -u UserName -h Host -p flush-privileges

 

mysql學習-----(2)

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.