安装了好多次,都是失败。终于给我安装好了。写一个我的安装流程吧,供大家借鉴借鉴。
使用homebrew安装mysql及遇到的问题
1、安装命令
brew install mysql
2、安装完成之后,本地命令行输入mysql命令,发现无此命令
commond not found
3、重新执行一遍
brew install mysql
这个时候我的结果就和我借鉴的不一样了我们先说一下别人的结果:
别人的结果和解决方法:
命令结果:
Warning: mysql-5.7.10 already installed, it's just not linked
然后网上查找解决方法,最后解决方法是执行:
brew link --overwrite mysql
但是执行,却报错
Linking /usr/local/Cellar/mysql/5.7.10...
Error: Could not symlink share/man/man8/mysqld.8
/usr/local/share/man/man8 is not writable.
又在网上各种查找解决方法,最后本地实验以下语句执行成功
sudo chown -R 'yin' /usr/local
注意:‘yin’是你电脑用户名
解决了问题后,重新执行:
brew link --overwrite mysql
提示:
Linking /usr/local/Cellar/mysql/5.7.10... 92 symlinks created
重新执行:
mysql -u root -p
但是又报错:(这个时候报的错和我一样,意思就是我直接跳过前面的了)
我报的错:
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)
这时百度上的,我借鉴的那个就没效果了。我就重新查找资料了!
查看mysql的安装位置:
huijundeMacBook-Pro:bin huijunzhang$ which mysql
/usr/local/bin/mysql
有路径,说明mysql还是安装过的
执行 brew info mysql
huijundeMacBook-Pro:bin huijunzhang$ brew info mysql
mysql: stable 5.7.13 (bottled)
Open source relational database management system
https://dev.mysql.com/doc/refman/5.7/en/
Conflicts with: mariadb, mariadb-connector-c, mysql-cluster, mysql-connector-c, percona-server
/usr/local/Cellar/mysql/5.7.13 (13,344 files, 445.0M) *
Poured from bottle on 2016-06-30 at 15:05:40
From: https://github.com/Homebrew/homebrew-core/blob/master/Formula/mysql.rb
==> Dependencies
Build: cmake ✘
Required: openssl ✔
==> Options
--with-archive-storage-engine
Compile with the ARCHIVE storage engine enabled
--with-blackhole-storage-engine
Compile with the BLACKHOLE storage engine enabled
--with-debug
Build with debug support
--with-embedded
Build the embedded server
--with-local-infile
Build with local infile loading support
--with-test
Build with unit tests
==> Caveats
We've installed your MySQL database without a root password. To secure it run:
mysql_secure_installation
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服务没有启动
huijundeMacBook-Pro:bin huijunzhang$ mysql.server start
Starting MySQL
. SUCCESS!
接下来要试试能否进入mysql了
huijundeMacBook-Pro:bin huijunzhang$ mysql
ERROR 1045 (28000): Access denied for user 'huijunzhang'@'localhost' (using password: NO)
这个提示应该很明显了吧,权限问题,mysql下没有huijunzhang这个用户,装过mysql的朋友应该知道,安装mysql默认的用户名是root,端口是3306,别问我为什么知道。。。
那就使用root用户启动:
huijundeMacBook-Pro:bin huijunzhang$ sudo mysql
Password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 4
Server version: 5.7.13 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>
mysql> show databases
-> ;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| sys |
+--------------------+
rows in set (0.01 sec)
至此,MySQL终于安装好了。
建立远程连接--Navicat
使用Navicat 12远程连接Mysql 8.0.11时会提示如下报错信息,从错误信息可知caching_sha2_password不能加载。
以上报错是由于目前已有的客户端连接软件还不支持Mysql8新增加的加密方式caching_sha2_password,所以我们需要修改用户的加密方式,将其改为老的加密验证方式。
大安装Mysql数据库的主机上登录Mysql对应的用户,上面连接时用的用户为root,所以我们登录root用户。
执行命令
select user,plugin from user where user='root';
可以看到当前用户的加密方式为caching_sha2_password
执行:
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'admin123';
将用户的加密方式改为mysql_native_password
执行命令flush privileges使权限配置项立即生效。
再次尝试连接Mysql,连接成功。
这样,经历了一番坎坷,终于成功了!
不知这个对你们是否有用,反正我就是这么弄得,并且成功了!
借鉴地址:
https://www.cnblogs.com/xuyatao/p/6932885.html
https://jingyan.baidu.com/album/3d69c551221c57f0ce02d779.html?picindex=2
https://blog.csdn.net/qq_20009015/article/details/81463315