安裝MySQL
yum install mysql mysql-server #輸入Y即可自動安裝,直到安裝完成
/etc/init.d/mysqld start #啓動MySQL
chkconfig mysqld on #設爲開機啓動
cp /usr/share/mysql/my-medium.cnf /etc/my.cnf #拷貝配置文件(注意:如果/etc目錄下面默認有一個my.cnf,直接覆蓋)
爲root賬戶設置密碼
mysql_secure_installation
#回車,根據提示輸入Y,輸入2次密碼,回車,根據提示一路輸入Y,最後出現:Thanks for using MySQL!
MySql密碼設置完成,重新啓動 MySQL:
/etc/init.d/mysqld restart #重啓
/etc/init.d/mysqld stop #停止
/etc/init.d/mysqld start #啓動