brew+mac安装mysql+密码_Mac brew install mysql8.0+ 修改登陆密码

在mac下安装mysql使用对密码的修改,常常忘记和屡次修改之后不知道使用的密码是什么,新安装的mysql使用的是空密码,使用的操做能够解决问题mysql

安装mysql:web

brew install mysql

Updating Homebrew...

Warning: mysql 8.0.12 is already installed and up-to-date

To reinstall 8.0.12, run `brew reinstall mysql`

mac下对mysql的启动、重启、中止操做命令sql

➜ ~ brew info mysql :查看数据库的基本信息

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

修改mysql密码策略数据库

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

查找mysql进程,查看mysql安装路径安全

ps -ef | grep mysql

使用下面的命令能够查看到mac电脑上安装mysql数据库时使用到的数据库信息,

启动的服务名称:/usr/local/Cellar/mysql/8.0.12/bin/mysqld

–basedir数据库存放的位置,

–plugin-dir插件的目录,

–log-error日志错误文件,

–pid-file进程文件服务器

➜ ~ ps aux | grep mysql

/usr/local/Cellar/mysql/8.0.12/bin/mysqld

--basedir=/usr/local/Cellar/mysql/8.0.12

--datadir=/usr/local/var/mysql

--plugin-dir=/usr/local/Cellar/mysql/8.0.12/lib/plugin

--log-error=cangckdeMacBook-Pro.local.err

--pid-file=/usr/local/var/mysql/cangckdeMacBook-Pro.local.pid

进入mysql安装路径 /usr/local/Cellar/mysql/8.0.11/binsvg

cd /usr/local/Cellar/mysql/8.0.11/bin

暂停mysql服务ui

mysql.server stop

修改密码策略,查看密码策略变量,不一样的版本使用的变量是不一致的,能够使用下面的变量来查看当前数据库中使用的策略变量插件

mysql> SHOW VARIABLES LIKE 'validate_password%';

+--------------------------------------+--------+

| Variable_name | Value |

+--------------------------------------+--------+

| validate_password.check_user_name | ON |

| validate_password.dictionary_file | |

| validate_password.length | 8 |

| validate_password.mixed_case_count | 1 |

| validate_password.number_count | 1 |

| validate_password.policy | MEDIUM |

| validate_password.special_char_count | 1 |

+--------------------------------------+--------+

7 rows in set (0.01 sec)

修改密码安全策略rest

PolicyTests Performed

0 or LOWLength

1 or MEDIUMLength; numeric, lowercase/uppercase, and special characters

2 or STRONGLength; numeric, lowercase/uppercase, and special characters; dictionary file

密码策略能够设置的值,1,2,3不一样的安全级别和使用的密码限制长度

set global validate_password.policy=0;

set global validate_password.length=1;

安全模式启动mysql

mysqld_safe --skip-grant-tables &

use mysql

flush privileges;

ALTER USER 'root'@'localhost' IDENTIFIED BY '新密码';

注意:重启mysql

mysql.server stop

mysql.server start

进入mysql交互模式

mysql -u root -p newpassworld

mysql默认只容许本地主机访问,修改设置运行外部程序能够访问电脑上的数据库

需更改 mysql 数据库里的 user表里的 host项

把localhost改称%

登陆mysql服务器,执行如下命令

mysql>use mysql;

mysql>update user set host = ‘%’ where user =’root’;

mysql>flush privileges;

mysql>quit

MySQLWorkbench 图形化界面操做数据库

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值