Linux MySQL的幾個重要目錄
1、資料庫目錄
/var/lib/mysql/
2、配置檔案
/usr/share /mysql(mysql.server指令及配置檔案)
3、相關指令
/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。
鍵入以下指令 :
[[email protected] local]# /usr/bin/mysqladmin -u root password123456
注:因為開始時root沒有密碼,是以-p舊密碼一項就可以省略了。
3、測試是否修改成功
1)不用密碼登入
[[email protected] local]# mysql
ERROR 1045: Access denied for user: '[email protected]' (Usingpassword: NO)
顯示錯誤,說明密碼已經修改。
2)用修改後的密碼登入
[[email protected] 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目錄下,在需要啟動時運作下面指令即可。
[[email protected] init.d]# /etc/init.d/mysql start另外安裝程式把MySQL安裝成了service,是以在任何目錄下都可以用:# service mysql start啟動LinuxMySQL。
2、停止
/usr/bin/mysqladmin -u root -p shutdown 或者:# service mysqlstop
3、自動啟動
1)察看mysql是否在自動啟動清單中
[[email protected] local]# /sbin/chkconfig –list
2)把Linux MySQL添加到你系統的啟動服務組裡面去
[[email protected] local]# /sbin/chkconfig – add mysql
3)把Linux MySQL從啟動服務組裡面删除。
[[email protected] local]# /sbin/chkconfig – del mysql