📄 1836.html
字号:
<br>
mysql> insert into friends (name, icq, telphone, address ) Values (<br>
-> "cxlin", "39425893", "7654321", "台北县"<br>
-> );<br>
Query OK, 1 row affected (0.01 sec)<br>
<br>
mysql> select * from friends;<br>
+-------+----------+----------+--------------+<br>
| name | telphone | icq | address |<br>
+-------+----------+----------+--------------+<br>
| maa | 29016710 | 46243046 | 台北县新庄市 |<br>
| cxlin | 7654321 | 39425893 | 台北县 |<br>
+-------+----------+----------+--------------+<br>
2 rows in set (0.00 sec)<br>
<br>
第二个 insert 指令指定了资料栏位的插入顺序,用法较第一个为弹性,而第一个指令<br>
必须依资料表建立结构时的顺序插入资料。<br>
<br>
更新、删除资料表记录:<br>
mysql> update friends set address = "桃园县" where name = "cxlin";<br>
Query OK, 1 row affected (0.00 sec)<br>
Rows matched: 1 Changed: 1 Warnings: 0<br>
<br>
mysql> select * from friends where name = "cxlin";<br>
+-------+----------+----------+---------+<br>
| name | telphone | icq | address |<br>
+-------+----------+----------+---------+<br>
| cxlin | 7654321 | 39425893 | 桃园县 |<br>
+-------+----------+----------+---------+<br>
1 row in set (0.00 sec)<br>
<br>
mysql> delete from friends where name = "maa";<br>
Query OK, 1 row affected (0.01 sec)<br>
<br>
mysql> select * from friends;<br>
+-------+----------+----------+---------+<br>
| name | telphone | icq | address |<br>
+-------+----------+----------+---------+<br>
| cxlin | 7654321 | 39425893 | 桃园县 |<br>
+-------+----------+----------+---------+<br>
1 row in set (0.00 sec)<br>
<br>
最後,建好资料库与资料表後,把addbook资料库中所有资料表的使用权限(select、<br>
insert、update、delete)授权给maa@localhost再次提醒, 此处的maa为mysql的使用者帐<br>
号,而非作业系统的maa帐号):<br>
mysql> grant select, insert, update, delete<br>
-> on addbook.*<br>
-> to maa@localhost identified by '1234567';<br>
Query OK, 0 rows affected (0.00 sec)<br>
之後,可用maa的身份进入mysql存取addbook资料库:<br>
<br>
# /usr/local/mysql/bin/mysql -u maa -p addbook<br>
Enter password:<br>
Reading table information for completion of table and column names<br>
You can turn off this feature to get a quicker startup with -A<br>
<br>
Welcome to the mysql monitor. Commands end with ; or g.<br>
Your mysql connection id is 211 to server version: 3.22.27<br>
<br>
Type 'help' for help.<br>
<br>
mysql> status<br>
--------------<br>
./mysql Ver 9.36 Distrib 3.22.27, for pc-linux-gnu (i686)<br>
<br>
Connection id: 26<br>
Current database: addbook<br>
Current user: maa@localhost<br>
Server version 3.22.27<br>
Protocol version 10<br>
Connection Localhost via UNIX socket<br>
UNIX socket /tmp/mysql.sock<br>
Uptime: 2 hours 29 min 33 sec<br>
<br>
Threads: 11 Questions: 107 Slow queries: 0 Opens: 11 Flush tables: 1<br>
Open 7<br>
--------------<br>
<br>
收回资料库使用权限的方法如下(以mysql root进入):<br>
mysql> revoke delete on addbook.* from maa@localhost;<br>
Query OK, 0 rows affected (0.00 sec)<br>
<br>
mysql> revoke all privileges on addbook.* from maa@localhost;<br>
Query OK, 0 rows affected (0.00 sec)<br>
第二个指令用来收回全部的权限。<br>
<br>
五、mysqladmin 公用程式的使用<br>
mysqladmin公用程式可用来维护mysql比较一般性的工作(新增、删除资料库、 设<br>
定使用者密码及停止mysql等等),详细的说明可以使用mysqladmin --help来查看。<br>
(以本文的安装为例mysqladmin位於/usr/local/mysql/bin/mysqladmin)。<br>
<br>
新增资料库 dbtest<br>
# /usr/local/mysql/bin/mysqladmin -u root -p create dbtest<br>
Enter password:<br>
Database "dbtest" created.<br>
删除资料库<br>
# /usr/local/mysql/bin/mysqladmin -u root -p drop dbtest<br>
Enter password:<br>
Dropping the database is potentially a very bad thing to do.<br>
Any data stored in the database will be destroyed.<br>
Do you really want to drop the 'dbtest' database [y/N]<br>
y<br>
Database "dbtest" dropped<br>
设定使用者密码(将 maa 的密码改为 7654321,mysqladmin 会先询问 maa 的原密码)<br>
# /usr/local/mysql/bin/mysqladmin -u maa -p password 7654321<br>
Enter password:<br>
#<br>
停止 mysql 服务<br>
# /usr/local/mysql/bin/mysqladmin -u root -p shutdown<br>
Enter password:<br>
注意,shutdown mysql後,必须由作业系统的root帐号执行下列指令才能启动mysql:<br>
# /usr/local/mysql/share/mysql/mysql.server start<br>
<br>
六、结语:<br>
mysql资料库的确是值得推广的一个产品,它的稳定性已经稳得大家的赞同, 只要你曾<br>
经学习过SQL Language(结构化查询语言),相信要摸熟mysql的使用只消一两个小时的时间。<br>
如果搭配PHP(Personal HomePage Program)和Apache Web Server, 更可很轻松建构一个与<br>
资料库结合的动态Web Site。如果再配合phpMyAdmin这个Web化的mysql管理工具,建立<br>
mysql的资料库和mysql的管理将会更加方便。<br>
<br>
参考资料与资源:<br>
http://www.tcx.se/<br>
mysql 3.23 Reference Manual<br>
The Apache Software Foundation<br>
PHP3 PHP Hypertext Preprocessor<br>
phpMyAdmin<br>
</FONT><br>
</TD>
</TR>
<TR>
<TD colSpan=2><FONT
class=middlefont></FONT><BR>
<FONT
class=normalfont>全文结束</FONT> </TD>
</TR>
<TR>
<TD background="images/dot.gif" tppabs="http://www.linuxhero.com/docs/images/dot.gif" colSpan=2
height=10></TD></TR></TBODY></TABLE></TD></TR></TBODY></TABLE></DIV></TD>
<TD vAlign=top width="20%"
background="images/line.gif" tppabs="http://www.linuxhero.com/docs/images/line.gif" rowSpan=2>
<DIV align=center>
<table class=tableoutline cellspacing=1 cellpadding=4
width="100%" align=center border=0>
<tr class=firstalt>
<td noWrap background="images/bgline.gif" tppabs="http://www.linuxhero.com/docs/images/bgline.gif" colspan=2 height=21>
<font class=normalfont><b>所有分类</b></font></td>
</tr>
<tr class=secondalt> <td noWrap width=27%> <font class=normalfont>1:</font> </td><td noWrap width=73%> <table width=100% border=0> <tr> <td><font class=normalfont><a href="type1.html" tppabs="http://www.linuxhero.com/docs/type1.html">非技术类</a></font></td> </tr> </table></td></tr><tr class=firstalt> <td noWrap width=27%> <font class=normalfont>2:</font> </td><td noWrap width=73%> <table width=100% border=0> <tr> <td><font class=normalfont><a href="type2.html" tppabs="http://www.linuxhero.com/docs/type2.html">基础知识</a></font></td> </tr> </table></td></tr><tr class=secondalt> <td noWrap width=27%> <font class=normalfont>3:</font> </td><td noWrap width=73%> <table width=100% border=0> <tr> <td><font class=normalfont><a href="type3.html" tppabs="http://www.linuxhero.com/docs/type3.html">指令大全</a></font></td> </tr> </table></td></tr><tr class=firstalt> <td noWrap width=27%> <font class=normalfont>4:</font> </td><td noWrap width=73%> <table width=100% border=0> <tr> <td><font class=normalfont><a href="type4.html" tppabs="http://www.linuxhero.com/docs/type4.html">shell</a></font></td> </tr> </table></td></tr><tr class=secondalt> <td noWrap width=27%> <font class=normalfont>5:</font> </td><td noWrap width=73%> <table width=100% border=0> <tr> <td><font class=normalfont><a href="type5.html" tppabs="http://www.linuxhero.com/docs/type5.html">安装启动</a></font></td> </tr> </table></td></tr><tr class=firstalt> <td noWrap width=27%> <font class=normalfont>6:</font> </td><td noWrap width=73%> <table width=100% border=0> <tr> <td><font class=normalfont><a href="type6.html" tppabs="http://www.linuxhero.com/docs/type6.html">xwindow</a></font></td> </tr> </table></td></tr><tr class=secondalt> <td noWrap width=27%> <font class=normalfont>7:</font> </td><td noWrap width=73%> <table width=100% border=0> <tr> <td><font class=normalfont><a href="type7.html" tppabs="http://www.linuxhero.com/docs/type7.html">kde</a></font></td> </tr> </table></td></tr><tr class=firstalt> <td noWrap width=27%> <font class=normalfont>8:</font> </td><td noWrap width=73%> <table width=100% border=0> <tr> <td><font class=normalfont><a href="type8.html" tppabs="http://www.linuxhero.com/docs/type8.html">gnome</a></font></td> </tr> </table></td></tr><tr class=secondalt> <td noWrap width=27%> <font class=normalfont>9:</font> </td><td noWrap width=73%> <table width=100% border=0> <tr> <td><font class=normalfont><a href="type9.html" tppabs="http://www.linuxhero.com/docs/type9.html">输入法类</a></font></td> </tr> </table></td></tr><tr class=firstalt> <td noWrap width=27%> <font class=normalfont>10:</font> </td><td noWrap width=73%> <table width=100% border=0> <tr> <td><font class=normalfont><a href="type10.html" tppabs="http://www.linuxhero.com/docs/type10.html">美化汉化</a></font></td> </tr> </table></td></tr><tr class=secondalt> <td noWrap width=27%> <font class=normalfont>11:</font> </td><td noWrap width=73%> <table width=100% border=0> <tr> <td><font class=normalfont><a href="type11.html" tppabs="http://www.linuxhero.com/docs/type11.html">网络配置</a></font></td> </tr> </table></td></tr><tr class=firstalt> <td noWrap width=27%> <font class=normalfont>12:</font> </td><td noWrap width=73%> <table width=100% border=0> <tr> <td><font class=normalfont><a href="type12.html" tppabs="http://www.linuxhero.com/docs/type12.html">存储备份</a></font></td> </tr> </table></td></tr><tr class=secondalt> <td noWrap width=27%> <font class=normalfont>13:</font> </td><td noWrap width=73%> <table width=100% border=0> <tr> <td><font class=normalfont><a href="type13.html" tppabs="http://www.linuxhero.com/docs/type13.html">杂项工具</a></font></td> </tr> </table></td></tr><tr class=firstalt> <td noWrap width=27%> <font class=normalfont>14:</font> </td><td noWrap width=73%> <table width=100% border=0> <tr> <td><font class=normalfont><a href="type14.html" tppabs="http://www.linuxhero.com/docs/type14.html">编程技术</a></font></td> </tr> </table></td></tr><tr class=secondalt> <td noWrap width=27%> <font class=normalfont>15:</font> </td><td noWrap width=73%> <table width=100% border=0> <tr> <td><font class=normalfont><a href="type15.html" tppabs="http://www.linuxhero.com/docs/type15.html">网络安全</a></font></td> </tr> </table></td></tr><tr class=firstalt> <td noWrap width=27%> <font class=normalfont>16:</font> </td><td noWrap width=73%> <table width=100% border=0> <tr> <td><font class=normalfont><a href="type16.html" tppabs="http://www.linuxhero.com/docs/type16.html">内核技术</a></font></td> </tr> </table></td></tr><tr class=secondalt> <td noWrap width=27%> <font class=normalfont>17:</font> </td><td noWrap width=73%> <table width=100% border=0> <tr> <td><font class=normalfont><a href="type17.html" tppabs="http://www.linuxhero.com/docs/type17.html">速度优化</a></font></td> </tr> </table></td></tr><tr class=firstalt> <td noWrap width=27%> <font class=normalfont>18:</font> </td><td noWrap width=73%> <table width=100% border=0> <tr> <td><font class=normalfont><a href="type18.html" tppabs="http://www.linuxhero.com/docs/type18.html">apache</a></font></td> </tr> </table></td></tr><tr class=secondalt> <td noWrap width=27%> <font class=normalfont>19:</font> </td><td noWrap width=73%> <table width=100% border=0> <tr> <td><font class=normalfont><a href="type19.html" tppabs="http://www.linuxhero.com/docs/type19.html">email</a></font></td> </tr> </table></td></tr><tr class=firstalt> <td noWrap width=27%> <font class=normalfont>20:</font> </td><td noWrap width=73%> <table width=100% border=0> <tr> <td><font class=normalfont><a href="type20.html" tppabs="http://www.linuxhero.com/docs/type20.html">ftp服务</a></font></td> </tr> </table></td></tr><tr class=secondalt> <td noWrap width=27%> <font class=normalfont>21:</font> </td><td noWrap width=73%> <table width=100% border=0> <tr> <td><font class=normalfont><a href="type21.html" tppabs="http://www.linuxhero.com/docs/type21.html">cvs服务</a></font></td> </tr> </table></td></tr><tr class=firstalt> <td noWrap width=27%> <font class=normalfont>22:</font> </td><td noWrap width=73%> <table width=100% border=0> <tr> <td><font class=normalfont><a href="type22.html" tppabs="http://www.linuxhero.com/docs/type22.html">代理服务</a></font></td> </tr> </table></td></tr><tr class=secondalt> <td noWrap width=27%> <font class=normalfont>23:</font> </td><td noWrap width=73%> <table width=100% border=0> <tr> <td><font class=normalfont><a href="type23.html" tppabs="http://www.linuxhero.com/docs/type23.html">samba</a></font></td> </tr> </table></td></tr><tr class=firstalt> <td noWrap width=27%> <font class=normalfont>24:</font> </td><td noWrap width=73%> <table width=100% border=0> <tr> <td><font class=normalfont><a href="type24.html" tppabs="http://www.linuxhero.com/docs/type24.html">域名服务</a></font></td> </tr> </table></td></tr><tr class=secondalt> <td noWrap width=27%> <font class=normalfont>25:</font> </td><td noWrap width=73%> <table width=100% border=0> <tr> <td><font class=normalfont><a href="type25.html" tppabs="http://www.linuxhero.com/docs/type25.html">网络过滤</a></font></td> </tr> </table></td></tr><tr class=firstalt> <td noWrap width=27%> <font class=normalfont>26:</font> </td><td noWrap width=73%> <table width=100% border=0> <tr> <td><font class=normalfont><a href="type26.html" tppabs="http://www.linuxhero.com/docs/type26.html">其他服务</a></font></td> </tr> </table></td></tr><tr class=secondalt> <td noWrap width=27%> <font class=normalfont>27:</font> </td><td noWrap width=73%> <table width=100% border=0> <tr> <td><font class=normalfont><a href="type27.html" tppabs="http://www.linuxhero.com/docs/type27.html">nfs</a></font></td> </tr> </table></td></tr><tr class=firstalt> <td noWrap width=27%> <font class=normalfont>28:</font> </td><td noWrap width=73%> <table width=100% border=0> <tr> <td><font class=normalfont><a href="type28.html" tppabs="http://www.linuxhero.com/docs/type28.html">oracle</a></font></td> </tr> </table></td></tr><tr class=secondalt> <td noWrap width=27%> <font class=normalfont>29:</font> </td><td noWrap width=73%> <table width=100% border=0> <tr> <td><font class=normalfont><a href="type29.html" tppabs="http://www.linuxhero.com/docs/type29.html">dhcp</a></font></td> </tr> </table></td></tr><tr class=firstalt> <td noWrap width=27%> <font class=normalfont>30:</font> </td><td noWrap width=73%> <table width=100% border=0> <tr> <td><font class=normalfont><a href="type30.html" tppabs="http://www.linuxhero.com/docs/type30.html">mysql</a></font></td> </tr> </table></td></tr><tr class=secondalt> <td noWrap width=27%> <font class=normalfont>31:</font> </td><td noWrap width=73%> <table width=100% border=0> <tr> <td><font class=normalfont><a href="type31.html" tppabs="http://www.linuxhero.com/docs/type31.html">php</a></font></td> </tr> </table></td></tr><tr class=firstalt> <td noWrap width=27%> <font class=normalfont>32:</font> </td><td noWrap width=73%> <table width=100% border=0> <tr> <td><font class=normalfont><a href="type32.html" tppabs="http://www.linuxhero.com/docs/type32.html">ldap</a></font></td> </tr> </table></td></tr> </table>
</DIV></TD></TR>
<TR vAlign=top>
<TD width="80%">
<DIV align=center><BR>
</DIV>
</TD></TR></TBODY></TABLE></TD></TR>
</TABLE></TD></TR>
</TABLE>
<TABLE cellSpacing=0 cellPadding=4 width="100%" bgColor=#eeeeee
border=0><TBODY>
<TR>
<TD width="50%">
<P><FONT class=middlefont>版权所有 © 2004 <A
href="mailto:bjchenxu@sina.com">linux知识宝库</A><BR>
违者必究. </FONT></P>
</TD>
<TD width="50%">
<DIV align=right><FONT class=middlefont>Powered by: <A
href="mailto:bjchenxu@sina.com">Linux知识宝库</A> Version 0.9.0 </FONT></DIV>
</TD></TR></TBODY></TABLE>
<CENTER></CENTER></TD></TR>
</TABLE></CENTER></BODY></HTML>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -