mysql基础

Posted on 2020-05-06 13:28  橙子j  阅读(178)  评论(0编辑  收藏  举报
C:\Users\JChen46>mysql -u root -p
Enter password: ******
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 6
Server version: 5.6.19 MySQL Community Server (GPL)

Copyright (c) 2000, 2014, 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> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| sakila             |
| test               |
| world              |
+--------------------+
6 rows in set (0.02 sec)

切换到某个数据库:

mysql> use test;
Database changed

查看test数据库下的所有表:

mysql> use test;
Database changed

创建数据库:

mysql> create database guest character set utf8;
Query OK, 1 row affected (0.33 sec)

增删改查:

https://www.cnblogs.com/Jasper-changing/p/11375720.html 

 

如果mysql提示不是内部或外部命令,参考https://www.cnblogs.com/angry-apple/p/9007014.html

把mysql.exe的路径添加到环境变量path中

 

备份:

例如将创建的aaa库备份到文件back_aaa中

   cd /home/data/mysql (进入到库目录)  
  
mysqldump -u root -p –opt aaa > back_aaa

参考:https://www.cnblogs.com/kingle-study/p/10005483.html

mysqldump -h ip地址 -P 端口 -u 用户名 -p 密码 --databases 多个数据库名 > /root/tmp/文件名.sql