MySQL常用命令与基本命令操作
1、MySQL常用命令
create database name; 创建数据库
use databasename; 选择数据库
drop database name 直接删除数据库,不提醒
show tables; 显示表
describe tablename; 表的详细描述
select 中加上distinct去除重复字段
mysqladmin drop databasename 删除数据库前,有提示。
显示当前mysql版本和当前日期
select version(),current_date;
2、修改mysql中root的密码:
shell>mysql -u root -p
mysql> update user set password=password(”xueok654123″) where user=’root’;
mysql> flush privileges //刷新数据库
mysql>use dbname; 打开数据库:
mysql>show databases; 显示所有数据库
mysql>show tables; 显示数据库mysql中所有的表:先use mysql;然后
mysql>describe user; 显示表mysql数据库中user表的列信息);
3、grant
创建一个可以从任何地方连接服务器的一个完全的超级用户,但是必须使用一个口令something做这个
mysql> grant all privileges on *.* to user@localhost identified by ’something’ with
增加新用户
格式:grant select on 数据库.* to 用户名@登录主机 identified by “密码”
GRANT ALL PRIVILEGES ON *.* TO monty@localhost IDENTIFIED BY ’something’ WITH GRANT OPTION;
GRANT ALL PRIVILEGES ON *.* TO monty@”%” IDENTIFIED BY ’something’ WITH GRANT OPTION;
删除授权:
mysql> revoke all privileges on *.* from root@”%”;
mysql> delete from user where user=”root” and host=”%”;
mysql> flush privileges;
创建一个用户custom在特定客户端it363.com登录,可访问特定数据库fangchandb
mysql >grant select, insert, update, delete, create,drop on fangchandb.* to custom@ it363.c
相关文档:
1、选取最适用的字段属性
MySQL 可以很好的支持大数据量的存取,但是一般说来,数据库中的表越小,在它上面执行的查询也就会越快。因此,在创建表的时候,为了获得更好的性能,我们可以将表中字段的宽度设得尽可能小。例如,在定义邮政编码这个字段时,如果将其设置为CHAR(255),显然给数据库增加了不必要的空间,甚至使用V ......
1、修改MySql数据库的my.ini配置文件、
# CLIENT SECTION
# ----------------------------------------------------------------------
#
# The following options will be read by MySQL client applications.
# Note that only client applications shipped by MySQL are guaranteed
# to read this section. If yo ......
根据Chaos Wang的PPT整理而成, 在此再次感谢Chaos Wang的此次TechTalk
基本概念
• 字符(Character)是指人类语言中最小的表义符号。例如'A'、'B'等;
• 给定一系列字符,对每个字符赋予一个数值,用数值来代表对应的字符,这一数值就是字符的编码(Encoding)。例如,我们给字符'A'赋予数值0,给字符'B'赋予数值 ......
在FC8中默认安装的有mysql,没有的话可以很方便的安装下。
默认的mysql的include文件目录在/usr/include/mysql
默认的mysql的lib文件夹在/usr/lib/mysql
这两个目录在我们编译时候需要到。
我的测试用的C代码为:
#include <stdio.h>
#include <stdlib.h>
#include <mysql.h>
#define CONN_HOST ......