发布日期:2014-03-21 13:22:14
  1. net stop mysql 注:停止mysql服务
  2. net start mysql 注:启动mysql服务
  3. mysql -u用户名 -p用户密码 注:登陆本机的mysql
  4. mysql -u用户名 -p用户密码 -h机器IP 注:登陆指定主机的mysql
  5. grant 权限 on 数据库.* to 用户名@登录主机 identified by "密码"
  6. grant select,insert,update,delete on *.* to user1@localhost Identified by "password1";
  7. show databases;
  8. use mysql;
  9. show tables;
  10. describe 表名;
  11. create database 库名;
  12. drop database 库名;
  13. drop database if exists drop_database;
  14. use 库名;
  15. create table 表名(字段列表);
  16. drop table 表名;
  17. delete from 表名;
  18. select * from 表名;
  19. mysqldump --opt test > mysql.test
  20. mysqlimport -u root -p123456 < < mysql.dbname
  21. load data local infile "文件名" into table 表名;
  22. source d:/mysql.sql;        注:执行sql文本文件
  23. /. d:/mysql.sql            注:执行sql文本文件
  24. delimiter ;                注:设置执行分割符
  25. mysql> select * fro \c   注:\c取消当前执行
  26. mysql> select * from tablename\G; 注:\G垂直显示表格内容
  27. mysql> select * from tablename\g 注:\g表示执行(go),可以代替执行分隔符;
  28. mysql> select * from tablename limit 3;  注:限制返回结果最大3条
  29. exit;        注:退出

 

mysql自解析的命令:

  1. ?         (\?) Synonym for `help'.
  2. clear     (\c) Clear command.
  3. connect   (\r) Reconnect to the server. Optional arguments are db and host.
  4. delimiter (\d) Set statement delimiter.
  5. edit      (\e) Edit command with $EDITOR.
  6. ego       (\G) Send command to mysql server, display result vertically.
  7. exit      (\q) Exit mysql. Same as quit.
  8. go        (\g) Send command to mysql server.
  9. help      (\h) Display this help.
  10. nopager   (\n) Disable pager, print to stdout.
  11. notee     (\t) Don't write into outfile.
  12. pager     (\P) Set PAGER [to_pager]. Print the query results via PAGER.
  13. print     (\p) Print current command.
  14. prompt    (\R) Change your mysql prompt.
  15. quit      (\q) Quit mysql.
  16. rehash    (\#) Rebuild completion hash.
  17. source    (\.) Execute an SQL script file. Takes a file name as an argument.
  18. status    (\s) Get status information from the server.
  19. system    (\!) Execute a system shell command.
  20. tee       (\T) Set outfile [to_outfile]. Append everything into given outfile.
  21. use       (\u) Use another database. Takes database name as argument.
  22. charset   (\C) Switch to another charset. Might be needed for processing binlog with multi-byte charsets.
  23. warnings  (\W) Show warnings after every statement.
  24. nowarning (\w) Don't show warnings after every statement.

 

发表评论