Home > Database > Mysql Tutorial > 送给新手---MySQL运用地前奏_MySQL

送给新手---MySQL运用地前奏_MySQL

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-06-01 13:53:00
Original
997 people have browsed it

  如果MYSQL运行在服务器上,而你在客户端需要连接的化,需要按如下方式进行连接:

shell>mysql -h host -u user -p

Enter password:************

  host和user分别代表MySQL服务器运行的主机名和MySQL帐户名.添写时写上对应的机器的名称和MySQL用户名. *********代表你的密码.

  如果有效,你会看到如下提示:

Welcome to the MySQL monitor. Commands end with ; or g.

Your MySQL connection id is 7 to server version: 5.0.18-nt

Type 'help;' or 'h' for help. Type 'c' to clear the buffer.

mysql>

  mysql>提示符告诉你该输入命令了.

  有些时候MySQL会允许你匿名登陆到服务器上,此时直接输入mysql即可.

shell> mysql

  成功连接后,可在mysql>提示下输入quit随时退出:

mysql> quit

Bye

  下面显示一个简单的查询实例,这是一个简单命令,要求得到服务器的版本号和当前日期:

mysql> select version(), current_date;

+-----------+--------------+

  version()   current_date  

+-----------+--------------+

  5.0.18-nt   2006-07-29  

+-----------+--------------+

1 row in set (0.00 sec)

mysql>

  在这里我们要明白:

  一个命令通常由SQL语句组成,随后跟着一个分号.

  MySQL的显示结果用表格(行和列)方式输出.第一行为列的标签,随后行为查询的结果.通常列标签是你查询的数据库表的列名,但若检索的是一表达式而非列值(如上一个例子),通常用表达式本身来标记列.

  随后它会显示返回了多少行以及查询时间,它提供了服务器性能的一个大致估计.它表示的是时钟时间并非CPU或机器时间.

  能够以大小写输入关键字,即在MySQL中大小写是等价的,但在一个查询语句中,要求大小写统一.

  以下是另一个查询:

mysql> SELECT SIN(PI()/4), (4+1)*5;

+------------------+---------+

  SIN(PI()/4)   (4+1)*5  

+------------------+---------+

  0.70710678118655   25  

+------------------+---------+

1 row in set (0.02 sec)

mysql>

Related labels:
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template