文章目錄
- 安裝MySQL
- 安全設定MySQL
- MySQL相關目錄和檔案
安裝MySQL
使用yum install命令安裝MySQL:
yum install mysql-server mysql
更簡單的方式,使用yum groupinstall命令:
yum groupinstall "MySQL Database server"
檢查mysqld服務是否正確安裝:
$ chkconfig --list mysqldmysqld 0:off 1:off 2:off 3:off 4:off 5:off 6:off
若有必要,還可以配置mysqld服務為開機自動啟動:
chkconfig mysqld on
手工啟動mysqld服務:
service mysqld start
安全設定MySQL
MySQL提供了一個mysql_secure_installation程式,以互動的方式協助我們調整安全方面的設定。
$ mysql_secure_installation
... ...In order to log into MySQL to secure it, we'll need the currentpassword for the root user. If you've just installed MySQL, andyou haven't set the root password yet, the password will be blank,so you should just press enter here.Enter current password for root (enter for none): ##輸入MySQL的root密碼,初始為空白OK, successfully used password, moving on...Setting the root password ensures that nobody can log into the MySQLroot user without the proper authorisation.Set root password? [Y/n] n ##是否需要重設root密碼? ... skipping.By default, a MySQL installation has an anonymous user, allowing anyoneto log into MySQL without having to have a user account created forthem. This is intended only for testing, and to make the installationgo a bit smoother. You should remove them before moving into aproduction environment.Remove anonymous users? [Y/n] ##是否需要刪除匿名帳號? ... Success!Normally, root should only be allowed to connect from 'localhost'. Thisensures that someone cannot guess at the root password from the network.Disallow root login remotely? [Y/n] ##是否禁用root帳號在其它電腦登入? ... Success!By default, MySQL comes with a database named 'test' that anyone canaccess. This is also intended only for testing, and should be removedbefore moving into a production environment.Remove test database and access to it? [Y/n] ##是否需要刪除test資料庫? - Dropping test database... ... Success! - Removing privileges on test database... ... Success!Reloading the privilege tables will ensure that all changes made so farwill take effect immediately.Reload privilege tables now? [Y/n] ##是否需要重新裝入授權資訊? ... Success!Cleaning up...All done! If you've completed all of the above steps, your MySQLinstallation should now be secure.Thanks for using MySQL!
MySQL相關目錄和檔案
/etc/my.cnf:MySQL伺服器設定檔。
/var/lib/mysql:MySQL資料目錄,可以通過my.cnf修改。
/usr/bin/mysqlamdin:MySQL伺服器命令列程式。
/usr/bin/mysql:MySQL用戶端命令列程式。