Mac创建本地数据库并连接

文章目录

一、下载安装MySql数据库

在MySql官网下载MySQL Community Server

可以选择默认配置安装数据库

二、查看本地MySQL

可以在本地"系统偏好设置"最下方,查看自己的MySql服务是否正常

也可以在终端输入查看,会提示你输入密码:

复制代码
/usr/local/mysql/bin/mysql -u root -p

Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 8
Server version: 8.2.0 MySQL Community Server - GPL

Copyright (c) 2000, 2023, Oracle and/or its affiliates.

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> 

三、Navcat连接数据库

如果提示连接失败,可以尝试

复制代码
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '你的密码';

错误的原因是由于从mysql5.7版本之后,验证方式默认从原来的mysql_native_password改成了caching_sha2_password,你如果下载安装的是最新的版本,那就会有这个问题。如果是安装包安装的5.7及以前版本则不存在此问题。

四、样例表脚本

mysql样例创建脚本

包含两个脚本 create.sql 和 populate.sql.

在客户端运行脚本可以创建出样例表

  • create.sql包含创建6个数据库表(包括所有主键和外键约束)的MySQL语句。
  • populate.sql包含用来填充这些表的INSERT语句。
相关推荐
熊文豪15 分钟前
MySQL迁移的“隐形坑”与电科金仓的“零改造”破局之道
数据库·mysql
AryShaw21 分钟前
macOS 上搭建 RK3568 交叉编译环境
linux·macos
火星数据-Tina35 分钟前
巨省Token:OpenClaw安装部署并接入数眼智能特价模型全流程(包含Windows和Mac)
windows·macos
萝卜白菜。1 小时前
ClassCastException: oracle.sql.BLOB cannot be cast to oracle.sql.BLOB问题
数据库·oracle
czlczl200209251 小时前
Mysql的多版本快照MVCC机制与Mysql四种隔离级别
数据库·mysql
有想法的py工程师1 小时前
PostgreSQL 事务隔离级别详解(以及与MySQL实现差异)
数据库·mysql·postgresql
chuxinweihui1 小时前
MySQL内外连接
数据库·mysql
杨云龙UP2 小时前
ODA服务器RAC节点2/u01分区在线扩容操作记录及后续处理流程(Linux LVM + ext4 文件系统在线扩容操作手册)_20260307
linux·运维·服务器·数据库·ubuntu·centos
parafeeee9 小时前
程序人生-Hello’s P2P
数据库·后端·asp.net
欲买桂花同载酒5829 小时前
程序人生-Hello’s P2P
运维·服务器·数据库