记录我在开发中经常用到的mysql命令和脚本,以作备用,最近有段时间没写sql了,有点生疏了。(以下是在winxp下开发的,打开命令提
记录我在开发中经常用到的mysql命令和脚本,以作备用,最近有段时间没写sql了,有点生疏了。
(以下是在winxp下开发的,打开命令提示符)。
第一招、mysql服务的启动和停止
net stop mysql
net start mysql
第二招、登陆mysql
语法是 mysql -h主机 -u用户名 -p秘密
例子是 mysql -hlocalhost -uroot -p123456
要确定mysql安装时候勾选了可以远程链接。如果登陆本地计算机,-h可以省略,键入命令mysql -uroot -p, 回车后提示你输入密码,,输入123456,然后回车即可进入到mysql中了。
第三招、增加新用户
语法是 grant 权限 on 数据库.表 to 用户名@登录主机 identified by “密码”
例子是
所有权限 grant all privalleges on zf.* to guqin@localhost identified by “123456″
select权限 grant all select on zf.* to guqin@localhost identified by “123456″
第四招、操作数据库
登录到mysql中,然后在mysql的提示符下运行下列命令,每个命令以分号结束。
1、 显示数据库列表。
show databases;
2、 显示库中的数据表。
use mysql;
show tables;
3、 显示数据表的结构。
desc 表明;
4、 建库与删库
create database 库名;
drop database 库名;
5、 建表和删表。
use 库名;
create table 表名(字段列表);
drop table 表名;
6、 清空表中记录。
delete from 表名;
7、 显示表中的记录。
select * from 表名;
第五招、导出和导入数据
1. 导出数据。
语法是 mysqldump –opt 库名.表名 > c:\data.sql
例子是 mysqldump -hlocalhost -uroot -p123456 zf.user>c:\data.sql
2. 导入数据:
语法是 mysqldump –opt 库名
例子是 mysqldump -hlocalhost -uroot -p123456 zf 或者
mysqlimport -hlocalhost -u root -p123456
3. 将文本数据导入数据库:
use 库名;
load data local infile “文件名” into table 表名;
第六招 创建一个数据库表
CREATE TABLE MYTABLE (name VARCHAR(20), sex CHAR(1));
第七招 往表中加入记录
insert into 表名 values (”1″,”2″);
第八招 用文本方式将数据装入数据库表中
LOAD DATA LOCAL INFILE “c:/data.sql” INTO TABLE 表名;
第九招 导入.sql文件命令(例如c:/data.sql)
use database;
source c:/data.sql
第十招 更新表中数据
update MYTABLE set sex=”f” where name=’hyq’;
第十一招 修复表
repair 表名
第十二招 查看表的大小
show 表名 status
第十三招 修改密码
mysqladmin -u用户名 -p旧密码 password “新密码”
第十四招 修改表结构
ALTER TABLE t1 MODIFY b BIGINT NOT NULL;
第十四招 退出MYSQL命令
exit or quit(回车)
以上是我的mysql操作命令,很方便。自己感觉比用gui操作好多了。

本篇文章给大家带来了关于mysql的相关知识,其中主要介绍了关于索引优化器工作原理的相关内容,其中包括了MySQL Server的组成,MySQL优化器选择索引额原理以及SQL成本分析,最后通过 select 查询总结整个查询过程,下面一起来看一下,希望对大家有帮助。

sybase是基于客户/服务器体系结构的数据库,是一个开放的、高性能的、可编程的数据库,可使用事件驱动的触发器、多线索化等来提高性能。

数据库系统由4个部分构成:1、数据库,是指长期存储在计算机内的,有组织,可共享的数据的集合;2、硬件,是指构成计算机系统的各种物理设备,包括存储所需的外部设备;3、软件,包括操作系统、数据库管理系统及应用程序;4、人员,包括系统分析员和数据库设计人员、应用程序员(负责编写使用数据库的应用程序)、最终用户(利用接口或查询语言访问数据库)、数据库管理员(负责数据库的总体信息控制)。

visual foxpro数据库文件是管理数据库对象的系统文件。在VFP中,用户数据是存放在“.DBF”表文件中;VFP的数据库文件(“.DBC”)中不存放用户数据,它只起将属于某一数据库的 数据库表与视图、连接、存储过程等关联起来的作用。

数据库的“完整性”是指数据的正确性和相容性。完整性是指数据库中数据在逻辑上的一致性、正确性、有效性和相容性。完整性对于数据库系统的重要性:1、数据库完整性约束能够防止合法用户使用数据库时向数据库中添加不合语义的数据;2、合理的数据库完整性设计,能够同时兼顾数据库的完整性和系统的效能;3、完善的数据库完整性有助于尽早发现应用软件的错误。

结构层次是“数据库→数据表→记录→字段”;字段构成记录,记录构成数据表,数据表构成了数据库。数据库是一个完整的数据的记录的整体,一个数据库包含0到N个表,一个表包含0到N个字段,记录是表中的行。

go语言可以写数据库。Go语言和其他语言不同的地方是,Go官方没有提供数据库驱动,而是编写了开发数据库驱动的标准接口,开发者可以根据定义的接口来开发相应的数据库驱动;这样做的好处在于,只要是按照标准接口开发的代码,以后迁移数据库时,不需要做任何修改,极大方便了后期的架构调整。

mysql查询为什么会慢,关于这个问题,在实际开发经常会遇到,而面试中,也是个高频题。遇到这种问题,我们一般也会想到是因为索引。那除开索引之外,还有哪些因素会导致数据库查询变慢呢?


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Dreamweaver CS6
Visual web development tools

SecLists
SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

MantisBT
Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

mPDF
mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

ZendStudio 13.5.1 Mac
Powerful PHP integrated development environment
