Mysql 库表操作初识
终端登录mysql
这里只演示win下, cmd 终端. 至于怎么在win下, linux, mac安装, 感觉这是一个入门级的百度搜索问题, 安装都搞不定, 确实有点尴尬, 好尴尬呀.
-- win R 输入cmd 进入控制台
C:Userschenjie> mysql -u root -p -- 回车
Enter password: ******** -- 回车
-- 成功进入了mysql客户端, 如果登录失败, 要么就是密码不对, 或者是服务没有开启.
Welcome to the MySQL monitor. Commands end with ; or g.
Your MySQL connection id is 19
Server version: 5.7.17-log MySQL Community Server (GPL)
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.
-- 打印 "hello,world!" 测试
mysql> select "hello, world!";
---------------
| hello, world! |
---------------
| hello, world! |
---------------
1 row in set (0.00 sec)
-- test
mysql> select now();
---------------------
| now() |
---------------------
| 2019-10-06 14:11:41 |
---------------------
1 row in set (0.00 sec)
mysql> select curdate() as "今日日期";
--------------
| 今日日期 |
--------------
| 2019-10-06 |
--------------
1 row in set (0.00 sec)
mysql> select database();
------------
| database() |
------------
| NULL |
------------
1 row in set (0.05 sec)
-- 查看所有的数据库
mysql> show databases;
--------------------
| Database |
--------------------
| information_schema |
| cj |
| flask_db |
| from_pdm |
| mysql |
| new_house |
| performance_schema |
| python_test_1 |
| sql_advance |
| stock_db |
| sys |
| test1 |
--------------------
19 rows in set (0.04 sec)
mysql> show variables like 'port';
--------------- -------
| Variable_name | Value |
--------------- -------
| port | 3306 |
--------------- -------
1 row in set (0.10 sec)
-- 查看数据库编码
mysql> show variables like "character%";
-------------------------- ----------------------------------
| Variable_name | Value |
-------------------------- ----------------------------------
| character_set_client | utf8mb4 |
| character_set_connection | utf8mb4 |
| character_set_database | utf8 |
| character_set_filesystem | binary |
| character_set_results | utf8mb4 |
| character_set_server | utf8 |
| character_set_system | utf8 |
| character_sets_dir | C:AppServMySQLsharecharsets |
-------------------------- ----------------------------------
8 rows in set (0.05 sec)
-- 查看某用户的权限
mysql> show grants for 'root'@'localhost';
---------------------------------------------------------------------
| Grants for [email protected] |
---------------------------------------------------------------------
| GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost' WITH GRANT OPTION |
| GRANT PROXY ON ''@'' TO 'root'@'localhost' WITH GRANT OPTION |
---------------------------------------------------------------------
2 rows in set (0.10 sec)
-- 查看数据库当前连接数, 并发数
mysql> show status like 'Threads%';
------------------- -------
| Variable_name | Value |
------------------- -------
| Threads_cached | 1 | -- 此线程中的空闲线程数
| Threads_connected | 4 |
| Threads_created | 5 | -- 最近一次启动服务,做创建的线程数
| Threads_running | 1 | -- 当前激活线程数
------------------- -------
4 rows in set (0.05 sec)
-- 查看数据文件存放路径
mysql> show variables like "