brew install mysql
详细参考 http://blog.neten.de/posts/2014/01/27/install-mysql-using-homebrew/
brew install mysql #安装
ln -sfv /usr/local/opt/mysql/*.plist ~/Library/LaunchAgents #开机启动项目
mysql.server start #启动mysql
mysql -u root #使用
运行一个mysql-server容器
自定义root密码为root
docker pull mysql-server #拉取官方镜像
docker run --name mysql -p 3306:3306 -e MYSQL_ROOT_PASSWORD=root -d mysql/mysql-server:latest
-p:将容器的端口发布到主机
-p, --publish=[] Publish a container's port(s) to the host
-d :后台运行并打印 container ID
-d, --detach Run container in background and print container ID
一定要先启动mysqld
命令行
brew安装mysql
brew install mysql
操作:
mysql -h127.0.0.1 -uroot -p
mysql> create database mydb
-> ;
Query OK, 1 row affected (0.00 sec)
mysql> show databases;#创建数据库
+--------------------+
| Database |
+--------------------+
| information_schema |
| mydb |
| mysql |
| performance_schema |
| sys |
+--------------------+
5 rows in set (0.00 sec)
mysql> use mydb;
Database changed
mysql> CREATE TABLE Persons ( Id int, Name varchar(255), Address varchar(255) );
Query OK, 0 rows affected (0.01 sec)
ssh连接:
docker-machine ssh containerID