专业编程教程与实战项目分享平台

网站首页 > 技术文章 正文

cmd命令操作Mysql数据库,命令行操作Mysql

ins518 2024-10-25 14:12:39 技术文章 7 ℃ 0 评论

Mysql数据库是比较流行的数据库之一,维基百科的介绍如下:

MySQL is an open-source relational database management system (RDBMS).In July 2013, it was the world's second most[a] widely used RDBMS, and the most widely used open-source client–server model RDBMS.It is named after Michael Widenius' (who is a co-founder of MySQL) daughter, My,while "SQL" stands as the abbreviation for Structured Query Language. The MySQL development project has made its source code available under the terms of the GNU General Public License, as well as under a variety of proprietary agreements. MySQL was owned and sponsored by a single for-profit firm, the Swedish company MySQL AB, now owned by Oracle Corporation.For proprietary use, several paid editions are available, and offer additional functionality.

大意就是Mysql数据库是开源的、流行的关系型数据库,现在被Oracle收购,但依然很流行!

今天要分享的是:windows系统cmd命令操作Mysql数据库!,好吧,废话不多说,开始今天的分享、、、、

1、你需要先安装Mysql数据库,其实就是安装Mysql数据库服务器,然后设置环境变量path,在cmd.exe里查询查看环境变量参数的命令是:path

2、第二步就是连接Mysql服务器,命令如下:mysql -h localhost -u root -p

回车之后输入密码,这个密码在安装的时候可以设置

3、查看可用的databases,命令就是show databases;

4、想用那个库都可以,只要输入命令use +要使用库就行,如use test,

查看有那些表show tables;

5、这个是我新安装的数据库,没有任何表,我现在就来新创建一个user_table表;

注意:命令行是以英文分号;为结束,只要没有分号,Mysql就认为命令没有输完,就不会执行命令。

6、现在就表示进入到test库,并可以执行自己的sql脚本了,但是一般在开发中这样操作,效率很低的,我们可以借助客户端来操作数据库,高效有方便,如:Navicat for MySQL

数据库的基本操作增加和查询,相关的数据库知识,我会在以后的经验中继续分享,欢迎大家继续关注我的经验。

这里用到的命令如下:

远程连接命令:mysql -h localhost -u root -p

显示数据库命令:show databases

显示表命令:show tables

注意:现在很少有人用命令行来操作数据库了,除了重构,查询表锁等,其它的可能都有装逼的嫌疑,不过练习一下命令,还是很不错的。

下期分享数据库操作的常用脚本语言和函数,左右连接查询和多种查询语句。欢迎大家关注微信公众账号:thiscode

Tags:

本文暂时没有评论,来添加一个吧(●'◡'●)

欢迎 发表评论:

最近发表
标签列表