标签:安装mysql nec exists inpu date string HERE current 更新
Homebrew简称brew,OSX上的软件包管理工具,在Mac终端可以通过brew安装、更新、卸载各种软件,(简直就是神器级武器)。
废话不多说,没安装brew自己去百度学习安装,这里就不多说了。
brew search mysql
brew install mysql@5.7
MySQL is configured to only allow connections from localhost by default
To connect run:
mysql -uroot
mysql@5.7 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 mysql@5.7 first in your PATH run:
echo ‘export PATH="/usr/local/opt/mysql@5.7/bin:$PATH"‘ >> ~/.bash_profile
For compilers to find mysql@5.7 you may need to set:
export LDFLAGS="-L/usr/local/opt/mysql@5.7/lib"
export CPPFLAGS="-I/usr/local/opt/mysql@5.7/include"
To have launchd start mysql@5.7 now and restart at login:
brew services start mysql@5.7
Or, if you don‘t want/need a background service you can just run:
/usr/local/opt/mysql@5.7/bin/mysql.server start
==> Summary
?? /usr/local/Cellar/mysql@5.7/5.7.23: 317 files, 234.1MB
以上信息需注意系统环境变量的配置:
echo ‘export PATH="/usr/local/opt/mysql@5.7/bin:$PATH"‘ >> ~/.bash_profile
# 文件修改以后执行写入bash_profile以后执行立即生效
sousers ~/.bash_profile
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,并出现无法登陆问题的解决方案,希望对大家有所帮助。
标签:安装mysql nec exists inpu date string HERE current 更新
原文地址:https://www.cnblogs.com/huangxiaotao/p/9713748.html