Homebrew(brew)安装MySQL成功后无法登录

Homebrew简称brew,OSX上的软件包管理工具,在Mac终端可以通过brew安装、更新、卸载各种软件,(简直就是神器级武器)。

废话不多说,没安装brew自己去百度学习安装,这里就不多说了。

1、首先在终端使用命令,这是搜索brew上的MySQL各个版本
brew search mysql
2、选择自己需要的版本,安装MySQL,这里我安装为5.7版本
brew install [email protected]
3、执行后稍等片刻,它会自动安装,以下为安装成功后显示的信息
MySQL is configured to only allow connections from localhost by default

To connect run:
    mysql -uroot

[email protected] is keg-only, which means it was not symlinked into /usr/local,
because this is an alternate version of another formula.

If you need to have [email protected] first in your PATH run:
  echo ‘export PATH="/usr/local/opt/[email protected]/bin:$PATH"‘ >> ~/.bash_profile

For compilers to find [email protected] you may need to set:
  export LDFLAGS="-L/usr/local/opt/[email protected]/lib"
  export CPPFLAGS="-I/usr/local/opt/[email protected]/include"

To have launchd start [email protected] now and restart at login:
  brew services start [email protected]
Or, if you don‘t want/need a background service you can just run:
  /usr/local/opt/[email protected]/bin/mysql.server start
==> Summary
??  /usr/local/Cellar/[email protected]/5.7.23: 317 files, 234.1MB

以上信息需注意系统环境变量的配置:

echo ‘export PATH="/usr/local/opt/[email protected]/bin:$PATH"‘ >> ~/.bash_profile

# 文件修改以后执行写入bash_profile以后执行立即生效
sousers ~/.bash_profile
4、最后执行,启动MySQL
mysql.server start

# 显示如下,则安装成功
Starting MySQL
. SUCCESS! 

附加:

终端输入

mysql -u root

如果你运气不好,出现如下错误,应该是修改初始密码没有成功

ERROR 1045 (28000): Access denied for user ‘root‘@‘localhost‘ (using password: YES),
解决步骤

(1)终端输入 mysqld_safe --skip-grant-tables 显示如下

mysqld_safe --skip-grant-tables

# 显示如下
2017-03-21T11:44:11.6NZ mysqld_safe Logging to ‘/usr/local/var/mysql/huang.local.err‘.
2017-03-21T11:44:11.6NZ mysqld_safe Logging to ‘/usr/local/var/mysql/huang.local.err‘.
2017-03-21T11:44:11.6NZ mysqld_safe A mysqld process already exists

(2)再次输入 mysql -u root 显示如下

Welcome to the MySQL monitor.  Commands end with ; or g.
Your MySQL connection id is 10
Server version: 5.7.17 Homebrew
Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type ‘help;‘ or ‘h‘ for help. Type ‘c‘ to clear the current input statement.
mysql>

(3)终端输入 use mysql显示如下

Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Database changed
mysql>

(4)修改密码 UPDATE mysql.user SET authentication_string=PASSWORD(‘你的密码‘) WHERE User=‘root‘;

成功  Query OK, 1 row affected, 1 warning (0.05 sec)
Rows matched: 1  Changed: 1  Warnings: 1

到这来就完成啦。

最后重新登终端输入:

mysql -u root -p

按回车键,输入设置的密码即可登录

以上所述给大家介绍的解决mac使用homebrew安装MySQL,并出现无法登陆问题的解决方案,希望对大家有所帮助。

原文地址:https://www.cnblogs.com/huangxiaotao/p/9713748.html

时间: 2024-08-06 07:49:07

Homebrew(brew)安装MySQL成功后无法登录的相关文章

mac使用brew安装mysql报RROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)

使用mac安装mysql安装完后运行 mysql -uroot -p 报了 ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2) 这是由于我们没有启动mysql,启动mysql使用 brew services start mysql或者 mysql.server start 在启动前我们可以设置一下root密码 mysql_secure_installation 然

Mac用brew安装MySQL

1.先安装brew 网址:https://brew.sh/ 复制命令:/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" 在终端运行 2.brew 安装mysql 输入命令:brew install [email protected]5.7 (可以指定版本安装,不指定版本默认最新版本) 3.修改环境变量 brew安装的东西都是在 /usr/l

Mac brew 安装mysql 报错 ERROR 2002 (HY000): Can't connect to local MySQL server through socket

安装mysql 最新版 56 brew install mysql 启动报错 ben:~ soul$ which mysql /usr/local/bin/mysql ben:~ soul$ mysql ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2) 解决办法 运行 ben:~ soul$ mysql.server start Starting MySQL .

Mac系统下 brew 安装mysql

brew 安装mysql 可以指定版本安装,不指定版本默认最新版本 brew install mysq[email protected] 修改环境变量 brew安装的东西都是在 /usr/local/Cellar/ 路径下,所有需要进到里面找到mysql然后一层一层进去直到找到bin目录,获取这时路径 我的电脑是: /usr/local/Cellar/[email protected]/5.7.23/bin (可能mysql版本不同,路径不同,自己切换目录找就ok) 1)终端输入命令 sudo

mac使用brew安装mysql

1.安装mysql #brew install mysql 报错 Error: The following directories are not writable by your user: /usr/local/lib You should change the ownership of these directories to your user. sudo chown -R $(whoami) /usr/local/lib 意思是 您应该将这些目录的所有权更改为您的用户 执行以下命令设置

Mac中使用brew安装mysql

若不考虑版本直接执行以下命令 brew install mysql 若要选择版本只要加上@版本即可,例如 brew install [email protected] 安装完后启动mysql mysql.server start 若服务未启动就会出现以下错误 ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2) 若要关闭mysql mysql.server stop

brew 安装 mysql

在网上看到各种教程,都会出现ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' 1. 确保环境没有mysql brew remove mysql brew cleanup 2. 安装 brew install mysql 3. 启动 brew services start mysql 设置开机启动:launchctl load ~/Library/LaunchAgents

Homebrew(brew)安装[email protected]及配置

查找并确定自己需要安装的版本 brew search mysql ==> Formulae automysqlbackup mysql-connector-c [email protected] mysql mysql-connector-c++ [email protected] mysql++ mysql-sandbox [email protected] ? mysql-client mysql-search-replace mysqltuner mysql-cluster mysql-u

yz总结centos7.5安装mysql并设置无密码登录

在CentOS中默认安装有MariaDB,这个是MySQL的分支,但为了需要,还是要在系统中安装MySQL,而且安装完成之后可以直接覆盖掉MariaDB. 1 下载并安装MySQL官方的 Yum Repository [[email protected] ~]# wget -i -c http://dev.mysql.com/get/mysql57-community-release-el7-10.noarch.rpm 使用上面的命令就直接下载了安装用的Yum Repository,大概25KB