mac nodejs 安装mysql_mac os 安装 MySQL

a659485c7479

mysql

业务需要最近需要用nodejs爬数据,并把数据存储在数据库。于是选择了mysql,在官网一顿下载,搞了半天没下载下来。 学习到一种快速便捷的方式。 homebrew 是个不错的工具

1. 使用Homebrew进行安装

homebrew 是一款 Mac OS 平台下的软件包管理工具,拥有安装、卸载、更新、查看、搜索等很多实用的功能。简单的一条指令,就可以实现包管理,而不用你关心各种依赖和文件路径的情况,十分方便快捷.

下载 homebrew 复制以下代码复制以下代码直接在终端回车执行即可;如果已有homebrew请忽略。

/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)

2. 安装mysql

brew install mysql

......

==> Caveats

We've installed your MySQL database without a root password. To secure it run:

mysql_secure_installation

MySQL is configured to only allow connections from localhost by default

To connect run:

mysql -uroot

To have launchd start mysql now and restart at login:

brew services start mysql

Or, if you don't want/need a background service you can just run:

mysql.server start

3. mysql 初始化

mysql_secure_installation

可能会出现这样的问题

Securing the MySQL server deployment.

Enter password for user root:

Error: Can't connect to local MySQL server through socket '/tmp/mysql.sock'

先执行一下 mysql.server start 然后再执行 mysql_secure_installation 即可

4. All done!

Securing the MySQL server deployment.

Connecting to MySQL using a blank password.

VALIDATE PASSWORD COMPONENT can be used to test passwords

and improve security. It checks the strength of password

and allows the users to set only those passwords which are

secure enough. Would you like to setup VALIDATE PASSWORD component?

Press y|Y for Yes, any other key for No: N

Please set the password for root here.

New password:

Re-enter new password:

By default, a MySQL installation has an anonymous user,

allowing anyone to log into MySQL without having to have

a user account created for them. This is intended only for

testing, and to make the installation go a bit smoother.

You should remove them before moving into a production

environment.

Remove anonymous users? (Press y|Y for Yes, any other key for No) : Y

Success.

Normally, root should only be allowed to connect from

'localhost'. This ensures that someone cannot guess at

the root password from the network.

Disallow root login remotely? (Press y|Y for Yes, any other key for No) : n

... skipping.

By default, MySQL comes with a database named 'test' that

anyone can access. This is also intended only for testing,

and should be removed before moving into a production

environment.

Remove test database and access to it? (Press y|Y for Yes, any other key for No) : y

- Dropping test database...

Success.

- Removing privileges on test database...

Success.

Reloading the privilege tables will ensure that all changes

made so far will take effect immediately.

Reload privilege tables now? (Press y|Y for Yes, any other key for No) : y

Success.

All done!

5. mysql

# 登录mysql

mysql -u root -p

# 然后输入密码,我的密码是123456

123456

# 退出mysql

exit

# 启动mysql

brew services start mysql

# 停止mysql

brew services stop mysql

# mysql 8.0 修改密码

ALTER user 'root'@'localhost' IDENTIFIED BY '111111';

好了什么都不说了,我要去撸*了😊

a659485c7479

雅蠛蝶

报错2:[解决MySQL8.0报错:Unknown system variable 'validate_password_policy'](https://www.bbsmax.com/A/ke5j2ml95r/

)

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值