文档详情

c程序对mysql操作.doc

发布:2018-05-03约3.36千字共4页下载文档
文本预览下载声明
1. mysql在linux下的编译和安装 [root@localhost zieckey]# mkdir /usr/local/mysql [root@localhost zieckey]# cp mysql-4.0.12.tar.gz /home/ [root@localhost root]# cd /home/ 解压 [root@localhost home]# tar zxvf mysql-4.0.12.tar.gz [root@localhost home]# cd mysql-4.0.12 配置,生成Makefile [root@localhost mysql-4.0.12]# ./configure --prefix=/usr/local/mysql --without-debug --with-extra-charsets=gb2312 --enable-assembler --without-isam --without-innodb --with-pthread --enable-thread-safe-client 编译 [root@localhost mysql-4.0.12]# make 安装 [root@localhost mysql-4.0.12]# make install [root@localhost mysql-4.0.12]# scripts/mysql_install_db 创建一个数据库管理员 [root@localhost mysql-4.0.12]# groupadd mysql [root@localhost mysql-4.0.12]# useradd -g mysql mysql 改变权限。 [root@localhost mysql]# chown -R root /usr/local/mysql [root@localhost mysql]# chown -R mysql /usr/local/mysql/var [root@localhost mysql]# chgrp -R mysql /usr/local/mysql 配置环境变量,以便于编程 [root@localhost mysql-4.0.12]# cd /usr/local/mysql/bin/ [root@localhost bin]# export PATH=$PATH:/usr/local/mysql/bin/ [root@localhost bin]# export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/mysql/lib/mysql/ [root@localhost bin]# env 启动mysql服务器 [root@localhost root]# cd /usr/local/mysql/bin/ [root@localhost bin]# ./mysqld_safe -u mysql Starting mysqld daemon with databases from /usr/local/mysql/var 查看是否启动了 [root@localhost root]# pgrep mysql 15931 15950 15951 启动一个mysql客户端 [root@localhost root]# /usr/local/mysql/bin/mysql Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 1 to server version: 4.0.12 Type help; or \h for help. Type \c to clear the buffer. mysql 创建一个数据库 mysql create database cusemysql; Query OK, 1 row affected (0.00 sec) 并使用这个数据库 mysql use cusemysql; Database changed 在给数据库内创建一个表 mysql create table children(childno int not null unique,fname varchar(20),age int); Query OK, 0 rows affected (0.00 sec) 在该表内插入一项数据 mysql insert into children values(5,花儿,10); Query OK, 1 row affected (0.00 sec) mysql select * f
显示全部
相似文档