欢迎来到天天文库
浏览记录
ID:48852312
大小:34.50 KB
页数:4页
时间:2020-02-02
《c语言操作mysql数据库.doc》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、1.mysql在linux下的编译和安装[root@localhostzieckey]#mkdir/usr/local/mysql[root@localhostzieckey]#cpmysql-4.0.12.tar.gz/home/[root@localhostroot]#cd/home/解压[root@localhosthome]#tarzxvfmysql-4.0.12.tar.gz[root@localhosthome]#cdmysql-4.0.12配置,生成Makefile[root@localhostmysql-4.0.1
2、2]#./configure--prefix=/usr/local/mysql--without-debug--with-extra-charsets=gb2312--enable-assembler--without-isam--without-innodb--with-pthread--enable-thread-safe-client编译[root@localhostmysql-4.0.12]#make安装[root@localhostmysql-4.0.12]#makeinstall [root@localhostmysq
3、l-4.0.12]#scripts/mysql_install_db 创建一个数据库管理员[root@localhostmysql-4.0.12]#groupaddmysql[root@localhostmysql-4.0.12]#useradd-gmysqlmysql 改变权限。[root@localhostmysql]#chown-Rroot/usr/local/mysql[root@localhostmysql]#chown-Rmysql/usr/local/mysql/var[root@localhostmysql]#c
4、hgrp-Rmysql/usr/local/mysql 配置环境变量,以便于编程[root@localhostmysql-4.0.12]#cd/usr/local/mysql/bin/[root@localhostbin]#exportPATH=$PATH:/usr/local/mysql/bin/[root@localhostbin]#exportLD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/mysql/lib/mysql/[root@localhostbin]#env 启动mys
5、ql服务器[root@localhostroot]#cd/usr/local/mysql/bin/[root@localhostbin]#./mysqld_safe-umysql&Startingmysqlddaemonwithdatabasesfrom/usr/local/mysql/var查看是否启动了[root@localhostroot]#pgrepmysql159311595015951 启动一个mysql客户端[root@localhostroot]#/usr/local/mysql/bin/mysqlWelcome
6、totheMySQLmonitor.Commandsendwith;org.YourMySQLconnectionidis1toserverversion:4.0.12 Type'help;'or'h'forhelp.Type'c'toclearthebuffer. mysql>创建一个数据库mysql>createdatabasecusemysql;QueryOK,1rowaffected(0.00sec) 并使用这个数据库mysql>usecusemysql;Databasechanged在给数据库内创建一个表mysql
7、>createtablechildren(childnointnotnullunique,fnamevarchar(20),ageint);QueryOK,0rowsaffected(0.00sec) 在该表内插入一项数据mysql>insertintochildrenvalues(5,"花儿",10);QueryOK,1rowaffected(0.00sec) mysql>select*fromchildren;+---------+-------+------+
8、childno
9、fname
10、age
11、+---------+---
12、----+------+
13、5
14、花儿
15、10
16、+---------+-------+------+1rowinset(0.03sec) mysql> 2.下面进行具体的操作/*insert.c*/#include#include
此文档下载收益归作者所有