




已阅读5页,还剩5页未读, 继续免费阅读
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
一、连接MYSQL。 格式: mysql -h主机地址 -u用户名 p用户密码 1、连接到本机上的MYSQL。 mysql -uroot -p2、连接到远程主机上的MYSQL。假设远程主机的IP为:10,用户名为root,密码为abcd123。则键入以下命令: mysql -h10 -uroot -pabcd123 (注:u与root可以不用加空格,其它也一样) 3、退出MYSQL命令: exit (回车) 二、修改密码。 格式:mysqladmin -u用户名 -p旧密码 password 新密码 注:因为开始时root没有密码,所以-p旧密码一项就可以省略了。 三、增加新用户。(注意:和上面不同,下面的因为是MYSQL环境中的命令,所以后面都带一个分号作为命令结束符) 格式:grant select on 数据库.* to 用户名登录主机 identified by 密码 例1、增加一个用户test1密码为abc,让他可以在任何主机上登录,并对所有数据库有查询、插入、修改、删除的权限。首先用以root用户连入MYSQL,然后键入以下命令: grant select,insert,update,delete on *.* to url=test1%/url Identified by abc; 但例1增加的用户是十分危险的,你想如某个人知道test1的密码,那么他就可以在internet上的任何一台电脑上登录你的mysql数据库并对你的数据可以为所欲为了,解决办法见例2。 例2、增加一个用户test2密码为abc,让他只可以在localhost上登录,并可以对数据库mydb进行查询、插入、修改、删除的操作(localhost指本地主机,即MYSQL数据库所在的那台主机),这样用户即使用知道test2的密码,他也无法从internet上直接访问数据库,只能通过MYSQL主机上的web页来访问了。 grant select,insert,update,delete on mydb.* to test2localhost identified by abc; 如果你不想test2有密码,可以再打一个命令将密码消掉。 grant select,insert,update,delete on mydb.* to test2localhost identified by ; 一、操作技巧 1、如果你打命令时,回车后发现忘记加分号,你无须重打一遍命令,只要打个分号回车就可以了。也就是说你可以把一个完整的命令分成几行来打,完后用分号作结束标志就OK。 2、你可以使用光标上下键调出以前的命令。但以前我用过的一个MYSQL旧版本不支持。我现在用的是mysql-3.23.27-beta-win。 二、显示命令 1、显示数据库列表。 show databases; 刚开始时才两个数据库:mysql和test。mysql库很重要它里面有MYSQL的系统信息,我们改密码和新增用户,实际上就是用这个库进行操作。 2、显示库中的数据表: use mysql; 打开库,学过FOXBASE的一定不会陌生吧 show tables; 3、显示数据表的结构: describe 表名; 4、建库: create database 库名; 5、建表: use 库名; create table 表名 (字段设定列表); 6、删库和删表: drop database 库名; drop table 表名; 7、将表中记录清空: delete from 表名; 8、显示表中的记录: select * from 表名; 三、一个建库和建表以及插入数据的实例 drop database if exists school; /如果存在SCHOOL则删除 create database school; /建立库SCHOOL use school; /打开库SCHOOL create table teacher /建立表TEACHER ( id int(3) auto_increment not null primary key, name char(10) not null, address varchar(50) default 深圳, year date ); /建表结束 /以下为插入字段 insert into teacher values(,glchengang,测试一,1976-10-10); insert into teacher values(,jack,测试一,1975-12-23); 注:在建表中(1)将ID设为长度为3的数字字段:int(3)并让它每个记录自动加一:auto_increment并不能为空:not null而且让他成为主字段primary key(2)将NAME设为长度为10的字符字段(3)将ADDRESS设为长度50的字符字段,而且缺省值为深圳。varchar和char有什么区别呢,只有等以后的文章再说了。(4)将YEAR设为日期字段。 如果你在mysql提示符键入上面的命令也可以,但不方便调试。你可以将以上命令原样写入一个文本文件中假设为school.sql,然后复制到c:下,并在DOS状态进入目录url=file:/mysqlbinmysqlbin/url,然后键入以下命令: mysql -uroot -p密码 school.bbb 注释:将数据库school备份到school.bbb文件,school.bbb是一个文本文件,文件名任取,打开看看你会有新发现。mysql 配置命令大全2006年07月10日 星期一 13:29-auto-rehash Enable automatic rehashing. One doesnt need to use rehash to get table and field completion, but startup and reconnecting may take a longer time. Disable with -disable-auto-rehash. -A, -no-auto-rehash No automatic rehashing. One has to use rehash to get table and field completion. This gives a quicker start of mysql and disables rehashing on reconnect. WARNING: options deprecated; use -disable-auto-rehash instead. -B, -batch Dont use history file. Disable interactive behavior. (Enables -silent) -character-sets-dir=name Directory where character sets are. -default-character-set=name Set the default character set. -C, -compress Use compression in server/client protocol. -#, -debug=# This is a non-debug version. Catch this and exit -D, -database=name Database to use. -delimiter=name Delimiter to be used. -e, -execute=name Execute command and quit. (Disables -force and history file) -E, -vertical Print the output of a query (rows) vertically. -f, -force Continue even if we get an sql error. -g, -no-named-commands Named commands are disabled. Use * form only, or use named commands only in the beginning of a line ending with a semicolon (;) Since version 10.9 the client now starts with this option ENABLED by default! Disable with -G. Long format commands still work from the first line. WARNING: option deprecated; use -disable-named-commands instead. -G, -named-commands Enable named commands. Named commands mean this programs internal commands; see mysql; help . When enabled, the named commands can be used from any line of the query, otherwise only from the first line, before an enter. Disable with -disable-named-commands. This option is disabled by default. -i, -ignore-spaces Ignore space after function names. -local-infile Enable/disable LOAD DATA LOCAL INFILE. -b, -no-beep Turn off beep on error. -h, -host=name Connect to host. -H, -html Produce HTML output. -X, -xml Produce XML output -line-numbers Write line numbers for errors. -L, -skip-line-numbers Dont write line number for errors. WARNING: -L is deprecated, use long version of this option instead. -no-tee Disable outfile. See interactive help (h) also. WARNING: option deprecated; use -disable-tee instead -n, -unbuffered Flush buffer after each query. -column-names Write column names in results. -N, -skip-column-names Dont write column names in results. WARNING: -N is deprecated, use long version of this options instead. -O, -set-variable=name Change the value of a variable. Please note that this option is deprecated; you can set variables directly with -variable-name=value. -sigint-ignore Ignore SIGINT (CTRL-C) -o, -one-database Only update the default database. This is useful for skipping updates to other database in the update log. -p, -password=name Password to use when connecting to server. If password is not given its asked from the tty. -W, -pipe Use named pipes to connect to server. -P, -port=# Port number to use for connection. -prompt=name Set the mysql prompt to this value. -protocol=name The protocol of connection (tcp,socket,pipe,memory). -q, -quick Dont cache result, print it row by row. This may slow down the server if the output is suspended. Doesnt use history file. -r, -raw Write fields without conversion. Used with -batch. -reconnect Reconnect if the connection is lost. Disable with -disable-reconnect. This option is enabled by default. -s, -silent Be more silent. Print results with a tab as separator, each row on new line. -shared-memory-base-name=name Base name of shared memory. -S, -socket=name Socket file to use for connection. -t, -table Output in table format. -T, -debug-info Print some debug info at exit. -tee=name Append everything into outfile. See interactive help (h) also. Does not work in batch mode. -u, -user=name User for login if not current user. -U, -safe-updates Only allow UPDATE and DELETE that uses keys. -U, -i-am-a-dummy Synonym for option -safe-updates, -U. -v, -verbose Write more. (-v -v -v gives the table output format). -V, -version Output version information and exit. -w, -wait Wait and retry if connection is down. -connect_timeout=# Number of seconds before connection timeout. -max_allowed_packet=# Max packet length to send to, or receive from server -net_buffer_length=# Buffer for TCP/IP and socket communication -select_limit=# Automatic limit for SELECT when using -safe-updates -max_join_size=# Automatic limit for rows in a join when using -safe-updates -secure-auth Refuse client connecting to server if it uses old (pre-4.1.1) protocolDefault options are read from the following files in the given order:C:WINDOWSmy.ini C:WINDOWSf C:my.ini C:fThe following groups are read: mysql clientThe following options may be given as the first argument:-print-defaults Print the program argument list and exit-no-defaults Dont read default options from any options file-defaults-file=# Only read default options from the given file #-defaults-extra-file=# Read this file after the global files are readVariables (-variable-name=value)and boolean options FALSE|TRUE Value (after reading options)- -auto-rehash TRUEcharacter-sets-dir (No default value)default-character-set latin1compress FALSEdatabase (No default value)delimiter ;vertical FALSEforce FALSEnamed-commands FALSElocal-infile FALSEno-beep FALSEhost (No default value)html FALSExml FALSEline-numbers TRUEunbuffered FALSEcolumn-names TRUEsigint-ignore FALSEport 3306prompt mysql;quick FALSEraw FALSEreconnect TRUEshared-memory-base-name (No default value)socket (No default value)table FALSEdebug-info FALSEuser (No default value)safe-updates TRUEi-am-a-dummy TRUEconnect_timeout 0max_allowed_packet 16777216net_buffer_length 16384select_limit 1000max_join_size 1000000secure-auth FALSE 一) 连接MYSQL:格式: mysql -h主机地址 -u用户名 p用户密码1、例1:连接到本机上的MYSQL首先在打开DOS窗口,然后进入mysql安装目录下的bin目录下,例如: D:mysqlbin,再键入命令mysql -uroot -p,回车后提示你输密码,如果刚安装好MYSQL,超级用户root是没有密码的,故直接回车即可进入到MYSQL中了,MYSQL的提示符是:mysql2、例2:连接到远程主机上的MYSQL假设远程主机的IP为:,用户名为root,密码为123。则键入以下命令:mysql -h -uroot -p123(注:u与root可以不用加空格,其它也一样)3、退出MYSQL命令exit (回车)(二) 修改密码:格式:mysqladmin -u用户名 -p旧密码 password 新密码1、例1:给root加个密码123。首先在DOS下进入目录C:mysqlbin,然后键入以下命令:mysqladmin -uroot -password 123注:因为开始时root没有密码,所以-p旧密码一项就可以省略了。2、例2:再将root的密码改为456mysqladmin -uroot -pab12 password 456(三) 增加新用户:(注意:和上面不同,下面的因为是MYSQL环境中的命令,所以后面都带一个分号作为命令结束符)
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 工业废弃物处理技术探索
- 工业大数据驱动制造业升级的引擎
- 工业安全管理的智能化发展
- 工业机器人技术及其优势
- 工业机器人技术的现状与趋势
- 工业污染防治技术与设备介绍
- 工业自动化中的质量控制与检测技术
- 工业级机房设计与环境控制技术
- 工业自动化与智能工艺技术发展
- 工业遗址保护与城市空间的整合
- 电子信息工程技术基础知识单选题100道及答案
- 走近核科学技术智慧树知到期末考试答案章节答案2024年兰州大学
- 99S203 消防水泵接合器安装图集
- 110kv油浸电力变压器基础知识介绍
- 期权基础知识2——期权价格及影响因素
- 青少版新概念英语1A单词表
- 14银行业金融机构从业人员处罚信息管理办法
- 肿瘤标志物及其临床意义
- 撒哈拉以南的非洲 区域地理知识总结精华
- 空压机保修手册
- (完整版)应急预案演练台帐
评论
0/150
提交评论