MySQL 学习笔记(一)

环境搭建
系统: macOs 10.12.6
MySQL安装包: mysql-8.0.13-macos10.14-x86_64
教材: MySQL Crash Course
书中数据下载: MySQL (and MariaDB)
运行MySQL
登陆 MySQL:

mysql -u root -p

新建数据库:

CREATE DATABASE learning;
USE learning;

载入数据:

SOURCE XXX(route)\mysql_scripts\create.sql;
SOURCE XXX(route)\mysql_scripts\populate.sql;

查看表:

SHOW TABLES;

检查表中是否有数据:

SELECT * FROM products;

书中范例数据库结构讲解
表的组成

表的内容及表之间的关系
在这里插入图片描述

出现错误:ERROR 1045 (28000): Access denied for user ‘root’@‘localhost’ (using password: NO)
解决:

mysql --password
mysql --user=root -p

参考博客:
https://blog.csdn.net/weixin_38215395/article/details/79854690

猜你喜欢

转载自blog.csdn.net/weixin_43790236/article/details/84454804