簡介Linux MySQL重要目錄與登錄密碼
特別值得一提的是Linux MySQL有很多值得學(xué)習(xí)的地方,這里我們主要介紹Linux MySQL,包括介紹Linux MySQL各種等方面。Linux MySQL安裝完成后不象SQL Server默認安裝在一個目錄,它的數(shù)據(jù)庫文件、配置文件和命令文件分別在不同的目錄,了解這些目錄非常重要,尤其對于Linux的初學(xué)者,因為 Linux本身的目錄結(jié)構(gòu)就比較復(fù)雜,如果搞不清楚Linux MySQL的安裝目錄那就無從談起深入學(xué)習(xí)。
下面就介紹一下這幾個目錄。
Linux MySQL的幾個重要目錄
1、數(shù)據(jù)庫目錄
/var/lib/mysql/
2、配置文件
/usr/share/mysql(mysql.server命令及配置文件)
3、相關(guān)命令
/usr/bin(mysqladmin mysqldump等命令)
4、啟動腳本
/etc/rc.d/init.d/(啟動腳本文件mysql的目錄)
Linux MySQL修改登錄密碼
Linux MySQL默認沒有密碼,安裝完畢增加密碼的重要性是不言而喻的。
1、命令
usr/bin/mysqladmin -u root password 'new-password'
格式:mysqladmin -u用戶名 -p舊密碼 password 新密碼
2、例子
例1:給root加個密碼123456。
鍵入以下命令 :
[root@test1 local]# /usr/bin/mysqladmin -u root password 123456
注:因為開始時root沒有密碼,所以-p舊密碼一項就可以省略了。
3、測試是否修改成功
1)不用密碼登錄
[root@test1 local]# mysql
ERROR 1045: Access denied for user: 'root@localhost' (Using password: NO)
顯示錯誤,說明密碼已經(jīng)修改。
2)用修改后的密碼登錄
[root@test1 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命令修改口令,也可通過修改庫來更改口令。
Linux MySQL啟動與停止
1、啟動
MySQL安裝完成后啟動文件mysql在/etc/init.d目錄下,在需要啟動時運行下面命令即可。
[root@test1 init.d]# /etc/init.d/mysql start 另外安裝程序把MySQL安裝成了service,所以在任何目錄下都可以用:# service mysql start啟動Linux MySQL。
2、停止
/usr/bin/mysqladmin -u root -p shutdown 或者:# service mysql stop
3、自動啟動
1)察看mysql是否在自動啟動列表中
[root@test1 local]# /sbin/chkconfig –list
2)把Linux MySQL添加到你系統(tǒng)的啟動服務(wù)組里面去
[root@test1 local]# /sbin/chkconfig – add mysql
3)把Linux MySQL從啟動服務(wù)組里面刪除。
[root@test1 local]# /sbin/chkconfig – del mysql
【編輯推薦】