-
在mac osx10.6下安装mysql后,启动总是报错ERROR 2002 (HY000): Can't connect to local MySQL ser5
要在mac10.6下安装mysql以便rails开发,装了两天都没有成功。之前没用过mac或linux开发,一直用windows,所以希望高手们能指点一下。
我在安装时参考了以下文章:
http://beike.iteye.com/blog/617341
http://hqman.iteye.com/blog/258979
下面是我的安装过程及错误:
安装和初始化mysqlport search mysql sudo port install mysql5-server ########################################################### # A startup item has been generated that will aid in # starting mysql5-server with launchd. It is disabled # by default. Execute the following command to start it, # and to cause it to launch at startup: # # sudo port load mysql5-server ########################################################### ---> Installing mysql5-server @5.1.50_0 ****************************************************** * In order to setup the database, you might want to run * sudo -u _mysql mysql_install_db5 * if this is a new install ****************************************************** ---> Activating mysql5-server @5.1.50_0 ---> Cleaning mysql5-server
sudo /opt/local/lib/mysql5/bin/mysql_install_db --user=mysql Installing MySQL system tables... OK Filling help tables... OK To start mysqld at boot time you have to copy support-files/mysql.server to the right place for your system PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER ! To do so, start the server, then issue the following commands: /opt/local/lib/mysql5/bin/mysqladmin -u root password 'new-password' /opt/local/lib/mysql5/bin/mysqladmin -u root -h bogon password 'new-password' Alternatively you can run: /opt/local/lib/mysql5/bin/mysql_secure_installation which will also give you the option of removing the test databases and anonymous user created by default. This is strongly recommended for production servers. See the manual for more instructions. You can start the MySQL daemon with: cd /opt/local ; /opt/local/lib/mysql5/bin/mysqld_safe & You can test the MySQL daemon with mysql-test-run.pl cd /opt/local/mysql-test ; perl mysql-test-run.pl Please report any problems with the /opt/local/lib/mysql5/bin/mysqlbug script!
配置mysql:
开机自动启动mysqlsudo launchctl load -w /Library/LaunchDaemons/org.macports.mysql5.plist
启动mysql
如果要快捷启动,则要先设置aliases,再用aliases来启动:
mate ~/.profile打开这个配置文件,输入以下内容:alias mysqlstart='sudo /opt/local/bin/mysqld_safe5 &' alias mysqlstop='/opt/local/bin/mysqladmin5 -u root -p shutdown'
启动mysqlmysqlstart [1] 62478
如果没有设置aliases,则用以下命令来启动
/opt/local/share/mysql5/mysql/mysql.server start
验证mysql安装成功:mysqladmin5 -u root -p ping error: 'Can't connect to local MySQL server through socket '/opt/local/var/run/mysql5/mysqld.sock' (2)' Check that mysqld is running and that the socket: '/opt/local/var/run/mysql5/mysqld.sock' exists!
或mysql5 -u root –p ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/opt/local/var/run/mysql5/mysqld.sock' (2)
mate /opt/local/etc/mysql5/my.cnf并输入以下内容(参考http://beike.iteye.com/blog/617341):[mysqld_safe] socket = /tmp/mysql.sock
再调用 mysql5 -u root –p还是报相同错误。
问题补充:引用试一下用这个命令能否连接:mysql5 -u root –p -h 127.0.0.1
我用这个命令就可以连接成功了,但如果不加-h 127.0.0.1就会报我的贴子中的错误,请问是什么原因?通过你提供的命令连接上去的应该也是一样使用的吧?是不是我以后用这个命令来连接就可以啦?
引用如果能连接,使用这个命令看看socket到底是什么?show variables like 'socket';
socket是:mysql> show variables like 'socket'; +---------------+-----------------+ | Variable_name | Value | +---------------+-----------------+ | socket | /tmp/mysql.sock | +---------------+-----------------+ 1 row in set (0.03 sec)
我调用这个命令得到的结果跟你的一样。2010年9月11日 17:04
3个答案 按时间排序 按投票排序
-
采纳的答案
试一下用这个命令能否连接:
mysql5 -u root –p -h 127.0.0.1
如果能连接,使用这个命令看看socket到底是什么?show variables like 'socket';
我是直接装的这个:http://www.mysql.com/downloads/mirror.php?id=392754
socket是:mysql> show variables like 'socket'; +---------------+-----------------+ | Variable_name | Value | +---------------+-----------------+ | socket | /tmp/mysql.sock | +---------------+-----------------+ 1 row in set (0.03 sec)
2010年9月14日 10:40
-
客户端程序连接时使用的socket和服务器使用的不一致,所以,连接不上。
不带任何参数运行mysqladmin时,输出里有如下文字:引用
Default options are read from the following files in the given order:
/etc/my.cnf /etc/mysql/my.cnf /usr/local/mysql/etc/my.cnf ~/.my.cnf
检查一下这些配置文件中,是否有任何地方使用了/opt/local/var/run/mysql5/mysqld.sock。2010年9月15日 11:26
相关推荐
- 在MAC OS X上安装MYSQL
- mac mysql 2002_在mac osx10.6下安装mysql后,启动总是报错ERROR 2002 (HY000): Can't connect to local MySQL ser...
- mysql.sock 2_Mac mySql ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/t...
- ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)
- mac mysql error 2002_mac os 启动mysql失败 ERROR 2002 HY000
相关推荐
PC安装MAC 10.6的安装说明: 1:选定黑苹果安装光盘镜像 2:将光盘内容烧录至U盘 3:给Win7安装Chameleon 4:开始安装Mac 5:安装苹果驱动、补丁
MAC OSX 10.6雪豹 VMWare虚机安装详细过程。
mysql-connector-odbc-5.1.13-osx10.6-x86-32bit.dmg // osx10.6 32位 mysql-connector-odbc-5.1.13-osx10.6-x86-64bit.dmg // osx10.6 64位 mysql-connector-odbc-5.1.13-osx10.7-x86-32bit.dmg // osx10.7 32位 ...
在PC上安装苹果OSX10.6雪豹系统全攻略.
双击mysql-8.0.0-dmr-osx10.11-x86_64.dmg进行解压, 安装。 Continue -> Continue, Agree -> Install。记录下来弹窗中的密码。 进入系统偏好设置, 找到mysql, 启动服务 将mysql的命令添加到系统中 (1).进入/usr/...
Mac OSX MySql 管理工具 Sequel-pro 非常好用,比Mysql Workbench 好用,试试就知道了.
Mac系统中制作Clover EFI引导的OS X 10.6_10.9各版本原版安装U盘又一法-制作-
【MAC版本】mysql-5.5.53-osx10.9-x86_64.dmg 官网下载巨慢,放这里加速下载方便使用
后来我还是直接到mysql 的官网下载了适合MAC 平台的 mysql-5.5.17-osx10.6-x86_64.dmg 打开后发现3个文件,安装顺序: 1。mysql-5.5.17-osx10.6-x86_64.pkg 数据库 2。MySQLStartupItem.pkg 这样MySQL就会自动在开机...
mac os x leopard的64位系统文件,boot.efi,直接替换,用于开启64位内核
go1.4.2.darwin-386-osx10.6.tar.gz go语言安装包
在MAC OSX中安装启动zookeeper1
Mac OSX系统 安装MySQL的方法
blender-2.71-OSX_10.6-x86_64.zip blender 2.71 for Mac OS X
硬盘安装Mac OSx 在XP系统下利用Mac硬盘安装助手软件写入Mac安装镜像文件和使用Boot think引导进行Mac硬盘安装
Mac.OSX_.Snow_.Leopard.Server.v10.6.3 torrent种子
mac OSX 系统 MySQL中文乱码解决办法
MAMP pro for mac (PHP/MySQL开发环境)是本地服务器环境的os x软件.MAMP pro for mac (PHP/MySQL开发环境)这几个首字母代表苹果的OSX系统上的Macintosh.Apache.MySQL和PHP!MAMP pro for mac (PHP/MySQL开发环境)内含...
虚拟机VMware 9安装苹果MAC OSX 10.8图文教程
Nginx 如何安装Magento 2x Mac或OSX,Nginx,MySQL,PHP(MEMP堆栈) 我的开发环境: Magento 2.3.x nginx/1.14.x PHP 7.2.x MySQL 5.7 macOS/OSX :10.13.6我将向所有人展示最佳实践,即如何使用Nginx在OSX上安装...