前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >MySQL Mac 安装与简单配置

MySQL Mac 安装与简单配置

作者头像
AnRFDev
发布2021-02-01 15:18:28
2K0
发布2021-02-01 15:18:28
举报
文章被收录于专栏:AnRFDevAnRFDev

homebrew安装mysql

使用brew命令安装mysql

代码语言:javascript
复制
mb:~ rustfisher$ brew install mysql

启动停止mysql服务

启动服务 mysql.server start 安装时没有设置密码,可以直接mysql -uroot登入。

代码语言:javascript
复制
mb:~ rustfisher$ mysql.server start
Starting MySQL
. SUCCESS! 

mb:~ rustfisher$ mysql -uroot
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 9
Server version: 8.0.12 Homebrew

Copyright (c) 2000, 2018, 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> exit;
Bye

输入mysql指令遇到错误

代码语言:javascript
复制
mysql> show database;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'database' at line 1

指令输入错误,修正一下

代码语言:javascript
复制
mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| sys                |
+--------------------+
4 rows in set (0.00 sec)

停止mysql服务的命令 mysql.server stop

代码语言:javascript
复制
mb:anindexserver rustfisher$ mysql.server stop
Shutting down MySQL
... SUCCESS! 

简单操作

更改密码

代码语言:javascript
复制
mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'yourpwd';
Query OK, 0 rows affected (0.05 sec)

设定了密码后,登录需要输入密码

代码语言:javascript
复制
mb:anindexserver rustfisher$ mysql -uroot -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.

参考:

可视化工具 mysql workbench

官方文档请参考 https://dev.mysql.com/downloads/workbench/

mysql workbench 需要primary key

需要有primary key才能编辑内容

https://stackoverflow.com/questions/10815029/mysql-workbench-edit-table-data-is-read-only

配置文件

mac中配置文件默认路径为 /usr/local/etc/my.cnf

可以修改port。

代码语言:javascript
复制
# Default Homebrew MySQL server config
[mysqld]
# Only allow connections from localhost
port=9527
bind-address = 127.0.0.1

这里限制了连接的端口。

参考: https://www.cyberciti.biz/faq/change-default-mysql-port-under-linuxunix/

本文参与 腾讯云自媒体分享计划,分享自作者个人站点/博客。
原始发表:2019-02-26,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • homebrew安装mysql
  • 启动停止mysql服务
  • 简单操作
    • 更改密码
    • 可视化工具 mysql workbench
      • mysql workbench 需要primary key
      • 配置文件
      相关产品与服务
      云数据库 SQL Server
      腾讯云数据库 SQL Server (TencentDB for SQL Server)是业界最常用的商用数据库之一,对基于 Windows 架构的应用程序具有完美的支持。TencentDB for SQL Server 拥有微软正版授权,可持续为用户提供最新的功能,避免未授权使用软件的风险。具有即开即用、稳定可靠、安全运行、弹性扩缩等特点。
      领券
      问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档