Install MySQL on MacOS

栏目: 数据库 · 发布时间: 6年前

内容简介:Install MySQL on MacOS

最近在家想写的东西,在MacOS上需要使用到MySQL。在MacOS下,使用brew来安装软件是最便捷。关于brew是什么,可在brew官网查看: brew官网

安装:

➜  ~ brew info mysql
mysql: stable 5.7.18 (bottled)
Open source relational database management system
......
➜  ~ brew install mysql

mysql的安装过程会显示,注,我安装的5.7.18,目录为 /usr/local/Cellar/mysql/5.7.18_1

==> /usr/local/Cellar/mysql/5.7.18_1/bin/mysqld –initialize-insecure –user=xiao –basedir=/usr/local/Cellar/mysql/5.7.18_1 –datadir=/usr/local/var/mysql –t
..... 
We’ve installed your MySQL database without a root password. To secure it run: 
mysql_secure_installation

这说明 MySQL 已安装成功,必需要使用mysql_secure_installation来初始化用户密码:

➜  ~ mysql.server start
Starting MySQL
SUCCESS!
➜  ~ mysql_secure_installation
Securing the MySQL server deployment.

Connecting to MySQL using a blank password.

......

按英文提示一步步设置password validation policy与password等。

测试,输入mysql_secure_installation设置过程的密码:

➜  ~ mysql -u root –p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 6
Server version: 5.7.18 Homebrew
......

新增用户xiao,密码为123456,并赋所有权限给他:

mysql>use mysql;
mysql>GRANT ALL PRIVILEGES ON *.* TO 'xiao'@'%' IDENTIFIED BY '123456' WITH GRANT OPTION;
mysql>flush privileges;

如果想设置开机启动MySQL,执行如下命令:

➜  ~ mkdir -p ~/Library/LaunchAgents
➜  ~ cp /usr/local/Cellar/mysql/5.7.18_1/homebrew.mxcl.mysql.plist ~/Library/LaunchAgents/  
➜  ~ launchctl load -w ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist

使用命令行来操作MySQL不方便,推荐使用Navicat MySQL/Preminum软件。软件安装包在网上搜索吧。

参考:

[1] https://dev.mysql.com/doc/refman/5.7/en/mysql-secure-installation.html


以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持 码农网

查看所有标签

猜你喜欢:

本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们

软件测试

软件测试

[美]Ron Patton / 张小松、王珏、曹跃 / 机械工业出版社 / 2006-4 / 30.00元

软件测试(原书第2版),ISBN:9787111185260,作者:(美)佩腾(Patton,R.) 著,张小松 等译;张小松译一起来看看 《软件测试》 这本书的介绍吧!

图片转BASE64编码
图片转BASE64编码

在线图片转Base64编码工具

UNIX 时间戳转换
UNIX 时间戳转换

UNIX 时间戳转换

HEX HSV 转换工具
HEX HSV 转换工具

HEX HSV 互换工具