免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 2940 | 回复: 0
打印 上一主题 下一主题

UnixWare 7.1.3/7.1.4平台上的MySQL数据库解决方案 [复制链接]

论坛徽章:
1
15-16赛季CBA联赛之北控
日期:2022-03-04 22:35:50
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2008-04-07 15:44 |只看该作者 |倒序浏览

出处:Unix爱好者家园unix-cd.com  
UnixWare 7.1.3/7.1.44内建PostgreSQL与MySQL数据库的资源, 而我们将以简单的范例
来解释如何于UnixWare 7.1.3/7.1.4平台上运用MySQL数据库的操作.
在安装完MySQL数据库后请依照以下步骤 (请先确定/usr/local/mysql/bin已经设定于$PATH变量中):
# ps -e|grep mysql
27475 pts/2 00:00:00 mysqld_safe
27506 pts/2 00:00:00 mysqld
27507 pts/2 00:00:00 mysqld
27508 pts/2 00:00:00 mysqld
27509 pts/2 00:00:00 mysqld
27510 pts/2 00:00:00 mysqld
27511 pts/2 00:00:00 mysqld
27512 pts/2 00:00:00 mysqld
27513 pts/2 00:00:00 mysqld
27514 pts/2 00:00:00 mysqld
27515 pts/2 00:00:00 mysqld
27688 pts/2 00:00:00 mysql
27689 pts/2 00:00:00 mysqld
若否, 可以利用这样的命令启动MySQL数据库 :
/etc/init.d/mysql start
(2) 建立数据库
# mysqladmin -uroot -pyour_passwd create testdb
(3) 连结到数据库, 并且切换至适才建立的数据库
# mysql -uroot -pyour_passwd
将能够看到类似以下的讯息
Welcome to the MySQL monitor. Commands end with  or \g.
Your MySQL connection id is 9 to server version:
4.0.18-standard
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
mysql>
(接着, 我们使用 use 命令切换数据库)
mysql> use testdb
Database changed
这表示已经切换到我们刚才建立的 testdb 数据库了
(4) 建立数据库所需的表格
我们可以利用这样的命令检查目前数据库内的table :
mysql> show tables;
Empty set (0.00 sec)
它会显示目前数据库内并没有任何表格存在
接着, 我们利用这样的命令建立表格 :
mysql> CREATE TABLE `clients` (
-> `id` int(11) NOT NULL auto_increment,
-> `name` text NOT NULL,
-> `address1` text NOT NULL,
-> `address2` text NOT NULL,
-> `city` text NOT NULL,
-> `postcode/zip` text NOT NULL,
-> `county` text NOT NULL,
-> `phone` text NOT NULL,
-> `fax` text NOT NULL,
-> KEY `id` (`id`)
-> ) TYPE=MyISAM AUTO_INCREMENT=1
Query OK, 0 rows affected (0.15 sec)
(5) 同时我们新增数据进去刚刚建立的表格内
mysql> INSERT INTO clients valueS (1,'Margaret Smith','123
The Street','Davidsons Mains','Edinburgh','EH4
1PD','Midlothian','+44 131 555 1234','+44 131 666 2345');
Query OK, 1 row affected (0.00 sec)
mysql> INSERT INTO clients valueS (2,'Jimbo Jones','34
Main Road','Leafy Suburb','Birmingham','BH4 7QD','','+44
666 666 7777','+44 666 666 9999');
Query OK, 1 row affected (0.00 sec)
mysql> INSERT INTO clients valueS (3,'Bernard
Worthington','1 Barnton Avenue','Leafy
Suburb','Birmingham','BH14 6QH','','+44 666 666 9999','+44
666 666 0000');
Query OK, 1 row affected (0.00 sec)
(6) 利用 select 命令取出适才新增的数据
mysql> select * from clients;
+--+------------+------------+---------+----------+--------------+--------+------+----------+
|id|    name    | address1   | address2|   city   | postcode/zip | county | phone|    fax   |
+--+------------+------------+---------+----------+--------------+--------+------+----------+
|1 | Margaret Smith | 123 The Street | DavidsonsMains | Edinburgh | EH4 1PD | Midlothian | +44 131
555 1234 | +44 131 666 2345 || 2 | Jimbo Jones | 34 Main Road | LeafySuburb | Birmingham | BH4 7QD | | +44
666 666 7777 | +44 666 666 9999 || 3 | Bernard Worthington | 1 Barnton Avenue | Leafy
Suburb | Birmingham | BH14 6QH | | +44666 666 9999 | +44 666 666 0000 |
+--+------------+------------+---------+----------+--------------+--------+------+----------+
3 rows in set (0.00 sec)
以上就是一个很简单的MySQL数据库操作范例


本文来自ChinaUnix博客,如果查看原文请点:http://blog.chinaunix.net/u/31/showart_520182.html
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP