最近打算重新學(xué)習(xí)一下mysql數(shù)據(jù)庫(kù)镜盯,手上正好有一個(gè)樹(shù)莓派详囤,正好那它來(lái)練手霜定。
在這里樹(shù)莓派的連接工具是Xshell 5噩翠。
mysql數(shù)據(jù)庫(kù)的連接工具是:Navicate Premium
這個(gè)界面是XShell的界面
Xshell 5 (Build 0964)
Copyright (c) 2002-2016 NetSarang Computer, Inc. All rights reserved.
Type `help' to learn how to use Xshell prompt.
[c:\~]$
這個(gè)是連接到樹(shù)莓派之后的界面
Connecting to 192.168.1.103:22...
Connection established.
To escape to local shell, press 'Ctrl+Alt+]'.
The programs included with the Debian GNU/Linux system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.
Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
permitted by applicable law.
Last login: Wed Nov 16 16:19:44 2016
pi@raspberrypi:~ $
1. 連接與斷開(kāi)服務(wù)器
登陸mysql巡球,并查看mysql的版本
pi@raspberrypi:~ $ mysql -u zhang -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 42
Server version: 5.5.52-0+deb8u1 (Raspbian)
Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> select version();
+-----------------+
| version() |
+-----------------+
| 5.5.52-0+deb8u1 |
+-----------------+
1 row in set (0.00 sec)
mysql>
退出mysql數(shù)據(jù)庫(kù)
mysql> quit
Bye
言沐,
mysql> exit
Bye
或者是按 Ctrl+D
2. 輸入查詢
mysql> select version(),current_date;
+-----------------+--------------+
| version() | current_date |
+-----------------+--------------+
| 5.5.52-0+deb8u1 | 2016-11-19 |
+-----------------+--------------+
1 row in set (0.00 sec)
mysql> select version(),current_date,host,user();
ERROR 1054 (42S22): Unknown column 'host' in 'field list'
mysql> select version(),current_date,user();
+-----------------+--------------+-----------------+
| version() | current_date | user() |
+-----------------+--------------+-----------------+
| 5.5.52-0+deb8u1 | 2016-11-19 | zhang@localhost |
+-----------------+--------------+-----------------+
1 row in set (0.00 sec)
mysql> -- 如果你輸入命令包含錯(cuò)誤,可以用\c進(jìn)行取消
mysql> select user()
-> \c
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| test |
+--------------------+
4 rows in set (0.00 sec)
mysql> -- 創(chuàng)建并使用數(shù)據(jù)庫(kù)
mysql> -- 查看當(dāng)前服務(wù)器上已經(jīng)存在的數(shù)據(jù)庫(kù)
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| test |
+--------------------+
4 rows in set (0.00 sec)
mysql> -- 使用數(shù)據(jù)庫(kù)
mysql> use test;
Database changed
mysql> -- 查看當(dāng)前使用過(guò)的數(shù)據(jù)庫(kù)
mysql> select database();
+------------+
| database() |
+------------+
| test |
+------------+
1 row in set (0.00 sec)
mysql> -- 創(chuàng)建并選擇數(shù)據(jù)庫(kù)
mysql> create database menagerie;
Query OK, 1 row affected (0.00 sec)
mysql> use menageries;
ERROR 1049 (42000): Unknown database 'menageries'
mysql> use menagerie;
Database changed
mysql> -- 也可以在連接數(shù)據(jù)庫(kù)的時(shí)候指定數(shù)據(jù)庫(kù)
mysql>