brew install mysql
mysql.server start
mysql.server stop
mysql -u root -p
$ ps ax | grep mysql
mysql> show databases
mysql> use <database name>
mysql> show tables
mysql> status
/usr/local/var/mysql
开启 MySQL 服务
mysql.server start
进入 MySQL 服务
mysql
执行 sql 语句
select version()
设置 root 的密码
mysqladmin -u root password '密码'
但是会出现一条警告:
mysqladmin: [Warning] Using a password on the command line interface can be insecure. Warning: Since password will be sent to server in plain text, use ssl connection to ensure password safety.
由于只是本机设置,先忽略
通过 Homebrew 安装 MySQL 的,卸载方法
http://stefan.magnuson.co/articles/osx/reinstalling-mysql-on-osx-with-homebrew/
mysqldump -u 用户名 -p 数据库名称 > 目标文件.sql