rpm可讓Linux在安裝軟件包時免除許多複雜的手續。該命令在安裝時常用的參數是 –ivh ,其中i表示將安裝指定的rmp軟件包,V表示安裝時的詳細信息,h表示在安裝期間出現“#”符號來顯示目前的安裝過程。這個符號將持續到安裝完成後才停 止。
在Ubuntu系統中安裝RPM格式軟件包的方法
Ubuntu的軟件包格式是deb,如果要安裝rpm的包,則要先用alien把rpm轉換成deb。
sudo apt-get install alien #alien默認沒有安裝,所以首先要安裝它
sudo alien xxxx.rpm #將rpm轉換位deb,完成後會生成一個同名的xxxx.deb
sudo dpkg -i xxxx.deb #安裝
不建議安裝MySQL
sudo apt-get install mysql-server
配置MySQL
注意,在Ubuntu下MySQL缺省是隻允許本地訪問的,如果你要其他機器也能夠訪問的話,那麼需要改變/etc/mysql/my.cnf配置文件了!下面我們一步步地來:
默認的MySQL安裝之後根用戶是沒有密碼的,所以首先用根用戶進入:
$mysql -u root
在這裏之所以用-u root是因爲我現在是一般用戶(firehare),如果不加-u root的話,mysql會以爲是firehare在登錄
進入mysql之後,最要緊的就是要設置Mysql中的root用戶密碼了,否則,Mysql服務無安全可言了。
mysql> GRANT ALL PRIVILEGES ON *.* TO root@localhost IDENTIFIED BY "123456"; //授予 root用戶 所有數據庫,所有表 全部權限 *.*; //會創建用戶,當然用戶存在的話則不必加"123456"
即創建用戶時不加 identified選項。否則創建的用戶帶密碼。除非顯示修改
注意,我這兒用的是123456做爲root用戶的密碼,但是該密碼是不安全的,請大家最好使用大小寫字母與數字混合的密碼,且不少於8位。
這樣的話,就設置好了MySQL中的root用戶密碼了,然後就用root用戶建立你所需要的數據庫。我這裏就以xoops爲例:
mysql>CREATE DATABASE xoops;
mysql>GRANT ALL PRIVILEGES ON xoops.* TO xoops_root@localhost IDENTIFIED BY "654321";
這樣就建立了一個xoops_roots的用戶,它對數據庫xoops有着全部權限。以後就用xoops_root來對xoops數據庫進行管理,而無需要再用root用戶了,而該用戶的權限也只被限定在xoops數據庫中。
如果你想進行遠程訪問或控制,那麼你要同時做兩件事:
其一:
mysql>GRANT ALL PRIVILEGES ON xoops.* TO xoops_root@"%" IDENTIFIED BY "654321";
允許xoops_root用戶可以從任意機器上登入MySQL。 %表示匹配任意 ,但有時這種方法可能失效,那就重新特定一下,不知道哪裏有問題。
其二:
$sudo gedit /etc/mysql/my.cnf
新的版本中
>bind-address=127.0.0.1 => bind-address= 你機器的IP
這樣就可以允許其他機器訪問MySQL了。bind表示綁定的監聽IP
On Unix, to install a compressed tar file binary distribution, unpack it at the installation location you choose (typically /usr/local/mysql). This creates the directories shown in the following table.
shell> mysql ;匿名登錄,如果服務器允許的話,
mysql> SHOW DATABASES;
mysql> USE test
USE
, like QUIT
, does not require a semicolon. (You can terminate such statements with a semicolon if you like; it does no harm.) The USE
statement is special in another way, too: it must be given on a single line.
mysql> QUIT
mysql> SELECT VERSION(), CURRENT_DATE;
+--------------+--------------+
| VERSION() | CURRENT_DATE |
+--------------+--------------+
| 5.5.0-m2-log | 2009-05-04 |
+--------------+--------------+
1 row in set (0.01 sec)
mysql>
Keywords may be entered in any lettercase. The following queries are equivalent:
mysql>SELECT VERSION(), CURRENT_DATE;
mysql>select version(), current_date;
mysql>SeLeCt vErSiOn(), current_DATE;
Here is another query. It demonstrates that you can use mysql as a simple calculator:
mysql> SELECT SIN(PI()/4), (4+1)*5;
+------------------+---------+
| SIN(PI()/4) | (4+1)*5 |
+------------------+---------+
| 0.70710678118655 | 25 |
+------------------+---------+
1 row in set (0.02 sec)
mysql> SELECT VERSION(); SELECT NOW();
A command need not be given all on a single line, so lengthy commands that require several lines are not a problem.
Here is a simple multiple-line statement:
mysql>SELECT
->USER()
->,
->CURRENT_DATE;
+---------------+--------------+ | USER() | CURRENT_DATE | +---------------+--------------+ | jon@localhost | 2005-10-11 | +---------------+--------------+
If you decide you do not want to execute a command that you are in the process of entering, cancel it by typing\c
: 取消已輸入但爲被執行的語句。
mysql>Here, too, notice the prompt. It switches back toSELECT
->USER()
->\c
mysql>
mysql>
after you type \c
, providing feedback to indicate thatmysql is ready for a new command.
Prompt | Meaning |
---|---|
mysql> | Ready for new command. |
-> | Waiting for next line of multiple-line command. |
'> | Waiting
for next line, waiting for completion of a string that began with a single quote (“' ”). |
"> | Waiting
for next line, waiting for completion of a string that began with a double quote (“" ”). |
`> | Waiting
for next line, waiting for completion of an identifier that began with a backtick (“` ”). |
/*> | Waiting
for next line, waiting for completion of a comment that began with /* . |
In MySQL, you can write strings surrounded by either “'
” or “"
” characters
mysql> SHOW DATABASES;
SELECT
DATABASE()
.
SHOW DATABASES
does not show databases that you have no privileges for if you do not have the SHOW DATABASES
privilege.
+----------+ | Database | +----------+ | mysql | (mysql數據庫存儲了用戶權限) | test | | tmp | +----------+
The mysql
database describes user access privileges. The test
database often is available as a workspace for users to try things out.
mysql> USE test
Database changed
USE
, like QUIT
, does not require a semicolon. (You can terminate such statements with a semicolon if you like; it does no harm.) The USE
statement is special in another way, too: it must be given on a single line.
mysql> CREATE DATABASE menagerie;
shell>mysql -h
Enter password:host
-uuser
-p menagerie********
mysql> SHOW TABLES;
mysql>CREATE TABLE pet (name VARCHAR(20), owner VARCHAR(20),
->species VARCHAR(20), sex CHAR(1), birth DATE, death DATE);
VARCHAR
is a good choice for the name
, owner
, and species
columns because the column values vary in length.