how to install MySQL on macOS

MySQL Community Server 8.0.21

# version
$ mysqladmin --version
# 8.0.21
$ mysql --version
# mysql Ver 8.0.21 for osx10.15 on x86_64 (Homebrew) $ mysqladmin --version
# mysqladmin Ver 8.0.21 for osx10.15 on x86_64 (Homebrew)

# start MySQL server once
$ mysql.server start # stop
$ mysql.server stop
# no password, connect
$ mysql -uroot

background service

# start MySQL server with background service
$ brew services start mysql # stop
$ brew services stop mysql

MySQL commands

# 查看所有数据库
mysql> show databases; # 创建数据库
mysql> create database test; # 选择数据库
mysql> use test; # 查看所有数据表
mysql> show tables; # 创建数据表, 推荐使用大写的的关键字
mysql> create table `demo_table`(
`table_id` INT UNSIGNED AUTO_INCREMENT,
`table_title` VARCHAR(100) NOT NULL,
`table_author` VARCHAR(40) NOT NULL,
`created_date` DATE,
PRIMARY KEY (`table_id`)
); # OR,
mysql> create table `demo_table`(`table_id` int unsigned auto_increment, `table_title` varchar(100) not null, `table_author` varchar(40) not null, `created_date` date, primary key (`table_id`)); # 操作数据表(插入数据)
mysql> insert into demo_table (table_title, table_author, created_date) VALUES ("MySQL Tutorials", "xgqfrms", now());
mysql> insert into demo_table (table_title, table_author, created_date) VALUES ("SQL Tutorials", "webgeeker", now()); # 操作数据表(查询)
mysql> select * from demo_table;
mysql> select table_title, table_author from demo_table;
mysql> select table_id, table_title, table_author, created_date from demo_table; # \G, 格式化输出,美化
mysql> select * from demo_table\G; # 操作数据表(修改数据)
mysql> update demo_table set table_title="DB Tutorials" where table_id=1; # 操作数据表(删除数据)
mysql> delete from demo_table where table_id=1; # 删除数据表
mysql> drop table demo_table; # 删除数据库
mysql> drop database test;

MySQL 语法

# 创建数据表的 SQL通用语法
# CREATE TABLE table_name (column_name column_type, ..., column_name column_type, ); CREATE TABLE IF NOT EXISTS `demo_table`(
`table_id` INT UNSIGNED AUTO_INCREMENT,
`table_title` VARCHAR(100) NOT NULL,
`table_author` VARCHAR(40) NOT NULL,
`created_date` DATE,
PRIMARY KEY ( `table_id` )
)ENGINE=InnoDB DEFAULT CHARSET=utf8;
# INSERT INTO 语句插入数据表中数据的通用语法

INSERT INTO table_name ( field1, field2,...fieldN ) VALUES  ( value1, value2,...valueN );

# 如果数据是字符型,必须使用单引号或者双引号,如:"value"

INSERT INTO demo_table
(table_title, table_author, created_date)
VALUES
("MySQL Tutorials", "xgqfrms", NOW());
# SELECT 语句查询数据表中数据的通用语法

SELECT column_name,column_name
FROM table_name
[WHERE Clause]
[LIMIT N][ OFFSET M];

# UPDATE 语句修改数据表中数据的通用语法

UPDATE table_name SET field1=new-value1, field2=new-value2
[WHERE Clause];

#  DELETE 语句删除数据表中数据的通用语法

DELETE FROM table_name [WHERE Clause];

.dmg install

mysql-8.0.21-macos10.15-x86_64.dmg

https://cdn.mysql.com//Downloads/MySQL-8.0/mysql-8.0.21-macos10.15-x86_64.dmg

manually install bug

$ sudo chmod +x ./mysqladmin

brew

# mysql
$ brew install mysql
# daemon mode(background service)
$ brew services start mysql $ brew services stop mysql
# avoid daemon mode(once)
$ mysql.server start $ mysql.server stop
$ mysql -u root -p

https://flaviocopes.com/mysql-how-to-install/

https://stackoverflow.com/questions/4359131/brew-install-mysql-on-macos

MySQL 5

mysql-5.7

https://dev.mysql.com/doc/mysql-osx-excerpt/5.7/en/osx-installation-pkg.html

MySQL 8

mysql-8.0.21

mysql-8.0.21-macos10.15-x86_64.tar.gz

https://dev.mysql.com/downloads/mysql/

refs

.pkg

go1.14.7.darwin-amd64.pkg



xgqfrms 2012-2020

www.cnblogs.com 发布文章使用:只允许注册用户才可以访问!


how to install MySQL on macOS的更多相关文章

  1. Install MySQL on Mac by Homebrew

    1.  安装mysql brew update brew install mysql 2. 启动mysql mysql.server start 3. 登录mysql mysql -uroot -p ...

  2. yum install mysql

    rpm -qa|grep -i mysqlmysql-libs-5.1.52-1.1.alios6.1.x86_64mysql-5.1.52-1.1.alios6.1.x86_64mysql-deve ...

  3. 在OSX狮子(Lion)上安装MYSQL(Install MySQL on Mac OSX)

    这篇文章简述了在Mac OSX狮子(Lion)上安装MySQL Community Server最新版本v10.6.7的过程. MySQL是最流行的开源数据库管理系统.首先,从MySQL的下载页面上下 ...

  4. ubuntu install mysql server method

         recently try to install mysql in my computer so that  I can practise some sql statement on seve ...

  5. macbook install mysql

    安装Homebrew,详细步骤参见Homebrew官网. brew doctor确认brew在正常工作. brew update更新包. brew install mysql 安装mysql.log如 ...

  6. install mysql from source and troubleshooting example

    I tried to install MySQL 5.7 from source file and upgrading previous MySQL version to the lastest 5. ...

  7. 执行了‘“npm install mysql"

    http是核心模块,封装到安装包里面了,如果在你项目的当前目录下<code>npm install mysql<code>的话就会在你当前目录下的node_modules文件夹 ...

  8. Install MySQL 5.7 on Fedora 25/24, CentOS/RHEL 7.3/6.8/5.11

    MySQL is a relational database management system (RDBMS) that runs as a server providing multi-user ...

  9. Install MySql on CentOS

    Installing & Configuring MySQL Server This Howto will show you how to install MySQL 5.x, start t ...

随机推荐

  1. 手写Netty之多路复用Select小案例

    注意:本文只是将上文多路复用器Select.Poll.Epoll区别梳理中提出的概念与Netty中的步骤联系起来,方便后面回顾,代码中注释很多,对于大家来说如果不是怀有同样的目的,不一定有用. 单线程 ...

  2. IDEA 2019 Unable to get current time from Google's servers 解决

    取消android support即可

  3. python 10函数式编程

                                                                               函数式编程 函数是Python内建支持的一种封装, ...

  4. RocketMQ 的几个简单问题与答案

    1 单机版消息中心 一个消息中心,最基本的需要支持多生产者.多消费者,例如下: class Scratch { public static void main(String[] args) { // ...

  5. 【进阶】ZooKeeper 相关概念总结

    1. 开卷有益 学习是一种习惯,只有把这种习惯保持下来,每天不学习一点就感觉浑身不自在,达到这样的境界,那么你成为大佬也就不远了买,正如我们标题所写的"开卷有益".人生匆匆,要想过 ...

  6. 题解 CF620E 【New Year Tree】

    有关dfs序的例题,需要有一定的位运算基础 题面 给定一个树,树上有颜色,将某一子树的颜色统一修改,求子树中颜色的数量 Solution 子树修改,子树求和,dfs序的知识(类似区间修改区间求和) 考 ...

  7. 前台console调试技巧

    前台console调试技巧 一.console.log() 二.console.warn() 三.console.dir() 四.console.table() 五.console.assert() ...

  8. c++复习笔记(4)

    这一篇是另一篇各种琐碎东西的笔记. 类型转换可以通过类型转换函数,或者构造函数来实现.但是一般来说类型转换指的是类型转换函数. 类型转换函数不需要声明输出类型(因为输出类型是固定的),也没有参数,同时 ...

  9. Centos 搭建Hadoop

    Centos搭建Hadoop 一.搭建Hadoop需要JDK环境,首先配置JDK 二.下载haoop 三.在Centos服务器上解压下载好的安装包 四.修改配置文件 4.1 hadoop-env.sh ...

  10. mysql高级day3

    Mysql高级-day03 1. 应用优化 前面章节,我们介绍了很多数据库的优化措施.但是在实际生产环境中,由于数据库本身的性能局限,就必须要对前台的应用进行一些优化,来降低数据库的访问压力. 1.1 ...