Mac下安装mysql及简单错误处理
2017-06-29 19:21
387 查看
1. 首先安装Homebrew
打开终端, 输入以下一行命令,等着下载完成。顺带一提, homebrew是Mac下的一款下载神器。/usr/bin/ruby -e “$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)”
2. 开始下载mysql
还是使用终端,输入以下一行命令brew install mysql
3. 然后就等着
看网速了,网速好,几分钟就下好了,网速差就多等会,下载好了后差不多就会如下图所示,注意 红框框 里面写的,就是下一步4. 在终端输入mysql_secure_installation
输入完msyql_secure_installation后,会让你做一些设置密码类的简单操作,密码最好由字母、符号和数字组成,不然好像系统会觉得你密码不够安全,会让你重输入,这个密码需要记住, 以后要用的。luoputekiMacBook-Air:~ luopu$ mysql_secure_installation Securing the MySQL server deployment. Enter password for user root: # 输入密码 The 'validate_password' plugin is installed on the server. The subsequent steps will run with the existing configuration of the plugin. Using existing password for root. Estimated strength of the password: 100 Change the password for root ? ((Press y|Y for Yes, any other key for No) : n # 选no就行了, 不用改,就是刚刚的密码 ... skipping. 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) : y # 禁止远程登陆 Success. 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! luoputekiMacBook-Air:~ luopu$
5. 搞定 + 进入mysql
luoputekiMacBook-Air:~ luopu$ mysql.server start # 启动mysql服务 Starting MySQL . SUCCESS! luoputekiMacBook-Air:~ luopu$ mysql -uroot -p # 相当于你即将进入一个可执行sql语句的地方 Enter password: # 输入之前设置的密码 Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 2 Server version: 5.7.16 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> # 此处可以输入sql语句,分号结尾, 回车执行
6. 简单错误处理
错误一
ERROR 2002 (HY000): Can’t connect to local MySQL server through socket ‘/tmp/mysql.sock’ (2)这个是因为mysql.server 没启动, 输入以下命令,回车
mysql.server start
错误二
luoputekiMacBook-Air:~ luopu$ mysql -vERROR 1045 (28000): Access denied for user ‘luopu’@’localhost’ (using password: NO)
这个是因为’luopu’没有权限,mysql下有个超级用户’root’,可以使用root解决该错误。举例:将图片中的
mysql -v改为
mysql -uroot -p -v即可。
错误三
ERROR 1064 (42000) at line 1: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ‘rsion’ at line 1在你写的sql语句中的
rsion附近由语法错误。
7. 推荐
慕课网mysql教程↗(^ω^)↗传送门走你相关文章推荐
- Mac下MySql安装经历(含安装错误排查、卸载多种折腾)
- MAC (Mountain Lion)+Eclipse+python+Django+PyDve+MySQL 安装错误解决办法
- mac-os下简单安装和配置mysql
- Linux CentOS 安装 Apache PHP MYSQL Memcached Memcache 环境配置 并且辅助安装遇见的错误处理(全文搜索
- 超级简单的mysql主从数据库配置攻略以及错误处理
- Linux下安装MySQL的流程及部分错误异常处理
- 免安装版MySQL安装完成后登陆1045错误处理
- autoconf安装错误,简单处理
- 启动命令mac安装mysql后,启动mysql ERROR 2002 (HY000)错误解决办法
- MySQL5.5.X安装错误处理
- mac安装mysql后,启动mysql ERROR 2002 (HY000)错误解决办法
- Mac安装OpenCV3 --with-contrib的错误处理
- 开源电商 OFBiz (Mysql)Idea安装过程及问题(中文乱码,500 GenericEntityException jdbc,Visitor错误处理)
- 重新安装mysql,发生错误怎么处理
- 批处理命令篇--配置免安装mysql 5.6.22, 以及1067错误的一个解决方法
- 在 Mac 中安装 MySQLdb (Python mysql )出现“mysql_config not found”错误的解决方法
- mac上安装mysql 以及root密码忘记或权限错误的解决办法
- mysql安装后,错误提示只有代码没有文字信息处理
- Mac安装MySQL、修改MySQL的初始化密码、默认字符集为utf-8以及配置完my.cnf的文件后仍不生效的情况下的处理方案
- Mac下MySql安装经历(含安装错误排查、卸载多种折腾)