命令行建立Mysql数据库的例子

木木老贼 互联网营销达人~

建立数据库我们可以很多的方式来创建了,小编来为各位介绍使用命令行建立Mysql数据库的例子,希望例子对各位有帮助,命令行下建立不同字符集的数据库、删除数据库:

  1. [root@lamp~]#/usr/local/mysql/bin/mysql-uroot-p'admin123'
  2. Warning:Usingapasswordonthecommandlineinterfacecanbeinsecure.
  3. WelcometotheMySQLmonitor.Commandsendwith;or\g.
  4. YourMySQLconnectionidis2
  5. Serverversion:5.6.16Sourcedistribution
  6. Copyright(c)2000,2014,Oracleand/oritsaffiliates.Allrightsreserved.
  7. mysql>createdatabasebyrd_default;#建议一个叫做byrd_default的数据库
  8. QueryOK,1rowaffected(0.08sec)
  9. mysql>showdatabaseslike'byrd%';#查看以byrd开头的数据库,
  10. +------------------+
  11. |Database(byrd%)|
  12. +------------------+
  13. |byrd_default|
  14. +------------------+
  15. 1rowinset(0.00sec)
  16. mysql>showcreatedatabasebyrd_default;#查看系统建立byrd_default命令,byrd_default默认编码是utf8,因为我编译mysql的时候设置的默认编码为utf8
  17. +--------------+-----------------------------------------------------------------------+
  18. |Database|CreateDatabase|
  19. +--------------+-----------------------------------------------------------------------+
  20. |byrd_default|CREATEDATABASE`byrd_default`/*!40100DEFAULTCHARACTERSETutf8*/|
  21. +--------------+-----------------------------------------------------------------------+
  22. 1rowinset(0.00sec)
  23. mysql>createdatabasegbkdefaultcharactersetgbkcollategbk_chinese_ci;#建立一个名字叫做gbk,编码方式是gbk的数据库
  24. QueryOK,1rowaffected(0.00sec)
  25. mysql>showcreatedatabasegbk;
  26. +----------+-------------------------------------------------------------+
  27. |Database|CreateDatabase|
  28. +----------+-------------------------------------------------------------+
  29. |gbk|CREATEDATABASE`gbk`/*!40100DEFAULTCHARACTERSETgbk*/|
  30. +----------+-------------------------------------------------------------+
  31. 1rowinset(0.00sec)
  32. mysql>showdatabases;#所有数据库表
  33. +--------------------+
  34. |Database|
  35. +--------------------+
  36. |information_schema|
  37. |byrd_default|
  38. |gbk|
  39. |gbk1|
  40. |gbk2|
  41. |gbk3|
  42. |gbk4|
  43. |mysql|
  44. |performance_schema|
  45. |test|
  46. |ultrax|
  47. +--------------------+
  48. 11rowsinset(0.00sec)
  49. mysql>dropdatabasegbk1;#删除名字为gbk1的数据库
  50. QueryOK,0rowsaffected(0.19sec)--phpfensi.com
  51. mysql>dropdatabasegbk2;
  52. QueryOK,0rowsaffected(0.00sec)
  53. mysql>dropdatabasegbk3;
  54. QueryOK,0rowsaffected(0.00sec)
  55. mysql>dropdatabasegbk4;
  56. QueryOK,0rowsaffected(0.01sec)
  57. mysql>showdatabases;
  58. +--------------------+
  59. |Database|
  60. +--------------------+
  61. |information_schema|
  62. |byrd_default|
  63. |gbk|
  64. |mysql|
  65. |performance_schema|
  66. |test|
  67. |ultrax|
  68. +--------------------+
  69. 7rowsinset(0.00sec)
  70. mysql>dropdatabaseifexistsbyrd_default;#如果byrd_default的数据库存在则删除,如果不存在则提示警告
  71. QueryOK,0rowsaffected(0.00sec)
  72. mysql>showdatabases;
  73. +--------------------+
  74. |Database|
  75. +--------------------+
  76. |information_schema|
  77. |gbk|
  78. |mysql|
  79. |performance_schema|
  80. |test|
  81. |ultrax|
  82. +--------------------+
  83. 6rowsinset(0.00sec)
  84. mysql>

相关广告
  • 命令行建立Mysql数据库的例子 命令行建立Mysql数据库的例子 命令行建立Mysql数据库的例子
相关阅读

命令行建立Mysql数据库的例子

2019/10/10 17:32:36 | 谷歌SEO算法 | Linus Torvalds