安裝mysql
以fedora環境下,直接輸入 yum install mysql及yum install mysql-server
啟動mysql
與一般服務的管理方式一樣,在fedora可以使用 service來管理,亦或是在 /etc/init.d下直接來管理服務。輸入 service mysqld restart,安裝後第一次啟動mysql,會提示你使用 mysqladmin -u root password 'your-password'來指定root密碼:
[root@Fedora8DK etc]# service mysqld start
Initializing MySQL database: Installing MySQL system tables...
OK
Filling help tables...
OK
To start mysqld at boot time you have to copy
support-files/mysql.server to the right place for your system
PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
To do so, start the server, then issue the following commands:
/usr/bin/mysqladmin -u root password 'new-password'
/usr/bin/mysqladmin -u root -h Fedora8DK password 'new-password'
See the manual for more instructions.
You can start the MySQL daemon with:
cd /usr ; /usr/bin/mysqld_safe &
You can test the MySQL daemon with mysql-test-run.pl
cd mysql-test ; perl mysql-test-run.pl
Please report any problems with the /usr/bin/mysqlbug script!
The latest information about MySQL is available on the web at
http://www.mysql.com
Support MySQL by buying support/licenses at http://shop.mysql.com
[ OK ]
Starting MySQL: [ OK ]
登入mysql
登入mysql的指令如下:
mysql [-h host_name][-u user_name][-pyour_pass ]
-h為要登入的主機名稱,可省略,未指定就是本機
-u為使用者名稱,可省略,未指定就是下指令的user
-p為密碼,如果有設密碼的話就不能省略。密碼不用先輸入,按下確定後系統會請你輸入密碼,如範例第二行
-h, -u和-p選項的另一種形式是--host=host_name、--user=user_name和--password=your_pass。注意在-p或--password=與跟隨它後面的口令之間沒有空格。
下面為指令範例:
[root@localhost ~]# mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 4
Server version: 5.0.45 Source distribution
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
mysql>
成功登入後,提示字元變成mysql>,代表現在在mysql底下。
登出mysql
輸入quit即可,或是按Ctrl+d也可以。
輸入查詢
這裡將介紹輸入命令的基本原則及特性。一般進入mysql後會顯示 mysql>,表示已經在mysql底下,並可以開始輸入命令,mysql>有幾個特性:
* 通常一個命令會以 ;(分號結尾),如果沒有";"即使按Enter鍵,mysql仍然會等待輸入(並非全部,像quit就不用以;結尾)
* mysql用資料表格(行和列)方式顯示查詢輸出。第一行包含列的標籤,隨後的行是查詢結果。通常,列標籤是您取自資料庫資料表的列的名字。
* 當執行完一個命令,mysql會將命令傳給伺服器,並將結果顯示出來,然後顯示另一個 mysql>等待下一個命令的輸入
* mysql的結果會顯示返回了多少行,以及查詢花了多長時間,它給您提供伺服器性能的一個大致概念。
* mysql底下不分大小寫,除了一些特定的字
底下為一些示範:
select version()使用version()來查詢現在的版本,底下輸出結果以及查詢所花費的時間。
mysql> select version();
+-----------+
| version() |
+-----------+
| 5.0.45 |
+-----------+
1 row in set (0.00 sec)
您可以在一行上輸入多條語句,只需要以一個;(分號)間隔開各語句:
mysql> select version(); select now();
+-----------+
| version() |
+-----------+
| 5.0.45 |
+-----------+
1 row in set (0.00 sec)
+---------------------+
| now() |
+---------------------+
| 2008-11-03 16:13:32 |
+---------------------+
1 row in set (0.00 sec)
你可以不用把所有的命令都集中在同一行,前面有說過,mysql以;(分號)做為結束符號,因此你也可以將命令分成好幾行,像這樣:
一樣使用select version();這個命令做示範,我將這個命令分成三行輸入,結果是一樣的。
mysql> select
-> version()
-> ;
+-----------+
| version() |
+-----------+
| 5.0.45 |
+-----------+
1 row in set (0.00 sec)
如果你在輸入到一半的想取消輸入,可以直接輸入 "\c"來取消輸入:
mysql> select
-> version()
-> \c
mysql>
這裡要注意一下,當我沒輸入;就按Enter的話,提示字元為 ->,其實每個符號各有不同的意思:
提示符號 含義
mysql> 準備好接受新的命令
-> 等待多行命令的下一行
'> 等待下一行,等待以單引號(「'」)開始的字串的結束。
"> 等待下一行,等待以雙引號(「"」)開始的字串的結束。
`> 等待下一行,等待以反斜點(『`』)開始的識別符的結束。
/*> 等待下一行,等待以/*開始的註釋的結束。
2010年6月1日
2010年5月26日
CentOS 5.4 升級 PHP
CentOS 5.4安裝myphpadmin 3.0以上會需要PHP版本5.2.0以上
然而內建的CentOS 5.4 使用yum update PHP最新版本也才到5.1.6
做法就是新增一個更新的位置
cd /etc/yum.repos.d
cp CentOS-Base.repo CentOS-test.repo
vi CentOS-test.repo
加入以下內容:
[C5-testing]
name=CentOS-5 Testing
baseurl=http://dev.centos.org/centos/5/testing/i386
enabled=1
gpgcheck=1
gpgkey=http://dev.centos.org/centos/RPM-GPG-KEY-CentOS-testing
然後yum update即可
然而內建的CentOS 5.4 使用yum update PHP最新版本也才到5.1.6
做法就是新增一個更新的位置
cd /etc/yum.repos.d
cp CentOS-Base.repo CentOS-test.repo
vi CentOS-test.repo
加入以下內容:
[C5-testing]
name=CentOS-5 Testing
baseurl=http://dev.centos.org/centos/5/testing/i386
enabled=1
gpgcheck=1
gpgkey=http://dev.centos.org/centos/RPM-GPG-KEY-CentOS-testing
然後yum update即可
2010年5月18日
How to add a custom CAPTCHA to phpBB2
某客戶留下的phpBB2被洗版 解決方法 安裝CAPTCHA方案
翻譯http://www.matthewleverton.com/howto/phpBB2-captcha.html
系統需求:
phpBB2
freecap
PHP 4/5 with GD enabled 確認是否有安裝->(rpm -qa|grep php-gd)
Admin Rights
安裝步驟:
1. 將freecap下載到phpbb網頁資料夾內
cd /phpbb
wget http://www.puremango.co.uk/freecap1.4.1.zip
unzip -a freecap1.4.1.zip
rm freecap1.4.1.zip
mv freecap1.4.1 freecap
2.找到phpBB內的樣式template資料夾 修改下面的profile_add_body.tpl,
例如\phpBB\template\subSilver\profile_add_body.tpl
3.將以下文字貼到profile_add_body.tpl檔案內, 建議是在password那段落的下面
下面的英文Cannot read the image?等,都可以改成你想要顯示的文字
4.以下原網頁第7步驟我沒做就OK了 有空再來翻譯..
Edit the phpBB2/includes/usercp_register.php file. (Remember to make a backup copy!) Around line 265, you'll see a block of code that says:
else if ( $mode == 'register' )
{
if ( empty($username) || empty($new_password) || empty($password_confirm) || empty($email) )
{
$error = TRUE;
$error_msg .= ( ( isset($error_msg) ) ? '
' : '' ) . $lang['Fields_empty'];
}
}
You need to add some lines to it, just in front of that closing brace. That section should look like:
else if ( $mode == 'register' )
{
if ( empty($username) || empty($new_password) || empty($password_confirm) || empty($email) )
{
$error = TRUE;
$error_msg .= ( ( isset($error_msg) ) ? '
' : '' ) . $lang['Fields_empty'];
}
session_start();
if (!isset($_POST['captcha']) || !isset($_SESSION['freecap_word_hash']) || $_SESSION['hash_func']($_POST['captcha']) != $_SESSION['freecap_word_hash'])
{
$error = TRUE;
$error_msg .= ( ( isset($error_msg) ) ? '
' : '' ) . "The word you entered did not match the image.";
}
unset($_SESSION['freecap_word_hash']);
}
Note that you are only adding those seven lines in bold!
翻譯http://www.matthewleverton.com/howto/phpBB2-captcha.html
系統需求:
phpBB2
freecap
PHP 4/5 with GD enabled 確認是否有安裝->(rpm -qa|grep php-gd)
Admin Rights
安裝步驟:
1. 將freecap下載到phpbb網頁資料夾內
cd /phpbb
wget http://www.puremango.co.uk/freecap1.4.1.zip
unzip -a freecap1.4.1.zip
rm freecap1.4.1.zip
mv freecap1.4.1 freecap
2.找到phpBB內的樣式template資料夾 修改下面的profile_add_body.tpl,
例如\phpBB\template\subSilver\profile_add_body.tpl
3.將以下文字貼到profile_add_body.tpl檔案內, 建議是在password那段落的下面
下面的英文Cannot read the image?等,都可以改成你想要顯示的文字
<tr>
<td class="row1"><span class="gen">CAPTCHA Image:</span><br />
<td class="row2">
<img id="freecap" src="/phpBB2/freecap/freecap.php" />
<div style="margin: 0.5em 0;">
<label style="font-size: 10px;" for="captcha">Word in Above Image:</label>
<input id="captcha" name="captcha" type="text" size="10" />
</div>
<div style="font-size: 10px;">
Cannot read the image?
<a href="#" onclick="document.getElementById('freecap').src='/phpBB2/freecap/freecap.php?'+Math.random();">Click Here</a>
to generate a new one.
</div>
</td>
</tr>
4.以下原網頁第7步驟我沒做就OK了 有空再來翻譯..
Edit the phpBB2/includes/usercp_register.php file. (Remember to make a backup copy!) Around line 265, you'll see a block of code that says:
else if ( $mode == 'register' )
{
if ( empty($username) || empty($new_password) || empty($password_confirm) || empty($email) )
{
$error = TRUE;
$error_msg .= ( ( isset($error_msg) ) ? '
' : '' ) . $lang['Fields_empty'];
}
}
You need to add some lines to it, just in front of that closing brace. That section should look like:
else if ( $mode == 'register' )
{
if ( empty($username) || empty($new_password) || empty($password_confirm) || empty($email) )
{
$error = TRUE;
$error_msg .= ( ( isset($error_msg) ) ? '
' : '' ) . $lang['Fields_empty'];
}
session_start();
if (!isset($_POST['captcha']) || !isset($_SESSION['freecap_word_hash']) || $_SESSION['hash_func']($_POST['captcha']) != $_SESSION['freecap_word_hash'])
{
$error = TRUE;
$error_msg .= ( ( isset($error_msg) ) ? '
' : '' ) . "The word you entered did not match the image.";
}
unset($_SESSION['freecap_word_hash']);
}
Note that you are only adding those seven lines in bold!
2010年4月27日
如何在遠端安裝好Red Enterprise Linux
[轉]如何在遠端安裝好Red Enterprise Linux一直是IT人員最大的困擾之一,例如您的客戶請您立刻為他安裝一部Red Hat Enterprise Linux,而這個客戶的地理位置遠在300公里之外,又例如您需要幫分公司安裝一部Red Hat Enterprise Linux,但分公司卻遠在泰國!為了解決這樣的困擾,Red Hat特地在Red Hat Enterprise Linux內加入遠端安裝 Red Hat Enterprise Linux的功能
在客戶主機
-以Red Hat Enterprise Linux DVD光碟開機,並在畫面上出現boot:之後輸入 boot: linux vnc
ip=192.168.0.100 netmask=255.255.255.0 dns=168.95.192.1 gateway=192.168.0.254
vncpassword=1233211234567
PS:假設192.168.0.100為Public IP
在我的電腦
-開啟vncviewer(不管Linux或Windows平台皆可),並輸入客戶主機的IP:1,如192.168.0.1
-輸入連接VNC Server所需的密碼,本範例為1233211234567
-接著客戶端主機的畫面就會呈現在vncviewer上,我們就可以像是坐在客戶主機前面一樣,把系統
裝好
在客戶主機
-以Red Hat Enterprise Linux DVD光碟開機,並在畫面上出現boot:之後輸入 boot: linux vnc
ip=192.168.0.100 netmask=255.255.255.0 dns=168.95.192.1 gateway=192.168.0.254
vncpassword=1233211234567
PS:假設192.168.0.100為Public IP
在我的電腦
-開啟vncviewer(不管Linux或Windows平台皆可),並輸入客戶主機的IP:1,如192.168.0.1
-輸入連接VNC Server所需的密碼,本範例為1233211234567
-接著客戶端主機的畫面就會呈現在vncviewer上,我們就可以像是坐在客戶主機前面一樣,把系統
裝好
2010年4月13日
Exchange 2010內建的反垃圾信功能-白名單
問題:台北縣警局tcpsung.gov.tw寄信過來被退信
訊息:您沒有權限傳送給此收件者。如需協助,請連絡您的系統管理員。
#5.7.1 smtp;550 5.7.1 Recipient not authorized, your IP has been found on a block list
解決方式:nslookup查詢對方的mail server ip, 在Exchange Management Console內
Microsoft Exchange內部部署-->伺服器設定-->集線傳輸-->(Server Name)-->反垃圾郵件-->IP允許清單-->右鍵內容-->允許的位置-->新增IP加入白名單
訊息:您沒有權限傳送給此收件者。如需協助,請連絡您的系統管理員。
解決方式:nslookup查詢對方的mail server ip, 在Exchange Management Console內
Microsoft Exchange內部部署-->伺服器設定-->集線傳輸-->(Server Name)-->反垃圾郵件-->IP允許清單-->右鍵內容-->允許的位置-->新增IP加入白名單
訂閱:
文章 (Atom)