转载请注明出处:http://www.cnblogs.com/blazer/p/5052318.html
mac10.10.4
mysql-5.7.10-osx10.10-x86_64
Mac小试牛刀,安装个mysql玩玩
默认安装到目录/usr/local下
dsmemberutil checkmembership -U mysql -G mysql
cd /usr/local
ln -s mysql-5.6.27-linux-glibc2.5-x86_64 mysql
cd mysql
# 将mysql/bin加入环境变量,也就是/etc/bashrc文件中
cat "export PATH=$PATH:/usr/local/mysql/bin " >> /etc/bashrc
# 加入默认配置文件
my_print_defaults命令可以看到
Default options are read from the following files in the given order:
/etc/my.cnf /etc/mysql/my.cnf /usr/local/mysql/etc/my.cnf ~/.my.cnf
# 我将my.cnf放到/etc/my.cnf
# 初始化数据文件
mysqld --initialize --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/mysql3306
mysql_ssl_rsa_setup
# 最后会出现
2015-12-16T12:12:43.106693Z 1 [Note] A temporary password is generated for root@localhost: T:NRzh/_3cPA
最后就是初始密码,将他改掉
mysqladmin -u root password 'root' -p
输入你的密码:T:NRzh/_3cPA
# 启动后先改密码
# 否则执行时指定配置文件
mysqld_multi --defaults-extra-file=/usr/local/mysql/my.cnf report
# or
mysqld_multi --defaults-file=/usr/local/mysql/my.cnf report
# or
mysqld_multi report
# 查看
mysqld_multi report
# 启动
mysqld_multi start 3306
# 停止
mysqld_multi stop 3306 --password=root
#or 最好用这个
mysqladmin -S /tmp/mysql_3306.sock -uroot -p shutdown
# 创建授权新用户,开始使用
GRANT ALL PRIVILEGES ON test.* TO 'hive_user'@'%' IDENTIFIED BY 'hive_user' WITH GRANT OPTION;
GRANT ALL PRIVILEGES ON *.* TO 'hive_user'@'%' IDENTIFIED BY 'hive_user' WITH GRANT OPTION;
revoke all on *.* from 'hive_user'@'%';
revoke all on test.* from 'hive_user'@'';
FLUSH PRIVILEGES;
delete from mysql.user where user='hive_user';
revoke all on *.* from 'hive_user'@'%';
FLUSH PRIVILEGES;
GRANT ALL PRIVILEGES ON *.* TO 'dev'@'%' IDENTIFIED BY 'dev123456' WITH GRANT OPTION;
FLUSH PRIVILEGES;
delete from mysql.user where user='dev';