一、 安裝並配置MySQL
1.1 執行yum 命令安裝MySQL
yum -y install mysql mysql-server |
1.2 把添加MySQL進開機啓動項,並立即啓動MySQL
chkconfig --levels 235 mysqld on/etc/init.d/mysqld start |
1.3 設置MySQL root帳號密碼
mysql_secure_installation |
NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MySQLSERVERS IN PRODUCTION USE!
PLEASE READ EACH STEP CAREFULLY!
In order to log into MySQL to secure it, we'll need the current password for the root user. If you've just installed MySQL, and you 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): <-- 輸入系統root密碼 OK, successfully used password, moving on... Setting the root password ensures that nobody can log into the MySQL root user without the proper authorisation. Set root password? [Y/n] <-- ENTER New password: <-- 你的MySQL root密碼 Re-enter new password: <-- 你的MySQL root密碼 Password updated successfully! Reloading privilege tables.. ... Success! By default, a MySQL installation has an anonymous user, allowing anyone to log into MySQL without having to have a user account created for
go a bit smoother. You should remove them before moving into a production environment. Remove anonymous users? [Y/n] <-- ENTER ... Success! Normally, root should only be allowed to connect from 'localhost'. This ensures that someone cannot guess at the root password from the network. Disallow root login remotely? [Y/n] <-- ENTER ... Success! By default, MySQL comes with a database named 'test' that anyone can
before moving into a production environment. Remove test database and access to it? [Y/n] <-- ENTER - Dropping test database... ... Success! - Removing privileges on test database... ... Success! Reloading the privilege tables will ensure that all changes made so far will take effect immediately. Reload privilege tables now? [Y/n] <-- ENTER ... Success! Cleaning up... All done! If you've completed all of the above steps, your MySQL installation should now be secure. Thanks for using MySQL! |
二、 安裝Apache
2.1 使用yum命令安裝Apache
yum –y install httpd |
2.2 設置開機啓動Apache
chkconfig --levels 235 httpd on |
2.3 啓動Apache
/etc/init.d/httpd start |
2.4 現在直接在瀏覽器鍵入http://localhost 或http://本機IP,應該會看到Apache的測試頁面
三、 安裝配置PHP
3.1 使用yum命令安裝PHP
yum –y install php |
3.2 重啓Apache服務器
/etc/init.d/httpd restart |
3.3 安裝相關模塊使用PHP支持MySQL:爲了讓PHP支持MySQL,我們可以安裝php-mysql軟件包;也可使用以下命令搜索可用的php模塊
yum search php |
選擇需要的模塊進行安裝
yum –y install php-mysql php-common php-mbstring php-gd php-imap php-ldap php-odbc php-pear php-xml php-xmlrpc |
3.4 重啓Apache服務器
/etc/init.d/httpd restart |
四、 安裝配置phpMyAdmin
安裝好MySQL,Apache及PHP後,爲了可視化的管理MySQL數據庫,我們需要安裝phpMyAdmin。
4.1 下載最新版本phpMyAdmin,下載地址:http://www.phpmyadmin.net/home_page/downloads.php ,選擇最新版本,如phpMyAdmin-3.5.2-all-languages.tar.bz2
4.2 解壓程序包
tar -xvf phpMyAdmin-3.5.2-all-languages.tar.bz2 |
4.3 移動目錄phpMyAdmin-3.5.2-all-languages到/usr/share/phpMyAdmin文件夾(建議手工操作,複製粘貼至/usr/share/目錄下,後重命名文件名爲phpMyAdmin,使用下面的命令行可能導致打開http://localhost/ phpmyadmin時,提示403錯誤,暫時不知怎麼回事- -!)
mv phpMyAdmin-3.5.2-all-languages /usr/share/phpMyAdmin |
4.4 進入phpMyAdmin目錄
cd /usr/share/phpMyAdmin |
4.5 拷貝樣本配置文件到config.inc.php文件
cp config.sample.inc.php config.inc.php |
4.6 修改Apache配置
vi /etc/httpd/conf.d/phpmyadmin .conf |
4.7 寫入如下內容
# Web application to manage MySQL #<Directory "/usr/share/phpMyAdmin"> # Order Deny,Allow # Deny from all # Allow from 127.0.0.1 #</Directory> Alias /phpmyadmin /usr/share/phpMyAdmin Alias /phpMyAdmin /usr/share/phpMyAdmin Alias /mysqladmin /usr/share/phpMyAdmin |
寫入並退出
4.8 重啓Apache服務器
/etc/init.d/httpd restart |
4.9 至此,打開頁面http://localhost/phpmyadmin 即可輕鬆管理你的mySQL數據庫
#####################################################################3333
mysql的一些筆記!
yum安裝mysql很是方便,但安裝好之後的問題卻搞了半天。
重載權限: mysql> FLUSH PRIVILEGES;
[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
user=mysql
default-character-set=utf8 [添加]
default-storage-engine=INNODB [添加]
old_passwords=1
[client]
default-character-set=utf8 [添加]
[mysqld_safe]
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid