Linux系統(tǒng)下MySQL重要目錄和密碼管理
linux操作系統(tǒng)與MySQL數(shù)據(jù)庫(kù)結(jié)合搭建的平臺(tái)為應(yīng)用程序的開發(fā)提供了保障。一個(gè)好的開發(fā)者在選擇開發(fā)環(huán)境時(shí)要考慮到開發(fā)平臺(tái)的安全性和穩(wěn)定性。本文主要介紹MySQL的幾個(gè)重要目錄以及MySQL數(shù)據(jù)庫(kù)的密碼管理,接下來就讓我們一起學(xué)習(xí)吧。
Linux MySQL的幾個(gè)重要目錄
1、數(shù)據(jù)庫(kù)目錄:/var/lib/mysql/。
2、配置文件:/usr/share/mysql(mysql.server命令及配置文件)。
3、相關(guān)命令:/usr/bin(mysqladmin mysqldump等命令)。
4、啟動(dòng)腳本:/etc/rc.d/init.d/(啟動(dòng)腳本文件mysql的目錄)。
Linux MySQL修改登錄密碼
Linux MySQL默認(rèn)沒有密碼,安裝完畢增加密碼的重要性是不言而喻的。
1、命令
- usr/bin/mysqladmin -u root password 'new-password'
 
格式:mysqladmin -u用戶名 -p舊密碼 password 新密碼
2、例子
例1:給root加個(gè)密碼123456。
鍵入以下命令 :
- [root@host local]# /usr/bin/mysqladmin -u root password 123456
 
注:因?yàn)殚_始時(shí)root沒有密碼,所以-p舊密碼一項(xiàng)就可以省略了。
3、測(cè)試是否修改成功
1)不用密碼登錄
- [root@host local]# mysql
 - ERROR 1045: Access denied for user: 'root@localhost' (Using password: NO)
 
顯示錯(cuò)誤,說明密碼已經(jīng)修改。
2)用修改后的密碼登錄
- [root@host local]# mysql -u root -p
 - Enter password: (輸入修改后的密碼123456)
 - Welcome to the MySQL monitor. Commands end with ; or \g.
 - Your MySQL connection id is 4 to server version: 4.0.16-standard
 - Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
 - mysql>
 
成功! 這是通過mysqladmin命令修改口令,也可通過修改庫(kù)來更改口令。
Linux MySQL啟動(dòng)與停止
1、啟動(dòng)
MySQL安裝完成后啟動(dòng)文件mysql在/etc/init.d目錄下,在需要啟動(dòng)時(shí)運(yùn)行下面命令即可。
- [root@host init.d]# /etc/init.d/mysql start
 
另外安裝程序把MySQL安裝成了service,所以在任何目錄下都可以用:# service mysql start啟動(dòng)Linux MySQL。
2、停止
- /usr/bin/mysqladmin -u root -p shutdown
 
或者:
- # service mysql stop
 
3、自動(dòng)啟動(dòng)
1)察看mysql是否在自動(dòng)啟動(dòng)列表中
- [root@host local]# /sbin/chkconfig –list
 
2)把Linux MySQL添加到你系統(tǒng)的啟動(dòng)服務(wù)組里面去
- [root@host local]# /sbin/chkconfig – add mysql
 
3)把Linux MySQL從啟動(dòng)服務(wù)組里面刪除。
- [root@host local]# /sbin/chkconfig – del mysql
 
到此,Linux下MySQL重要目錄及密碼管理已經(jīng)介紹完畢,如果想了解更多的MySQL數(shù)據(jù)庫(kù)知識(shí),可以看一下這里的文章:http://database.51cto.com/mysql/。
【編輯推薦】















 
 
 

 
 
 
 