MySQL is not found anywhere on computer

元气小坏坏 提交于 2019-12-21 21:58:41

问题


I have recently installed MySQL directly from the website (mysql-5.7.9-osx10.10-x86_64.dmg) and I have run into a great deal of difficulty that started with trying to change the given password. The error that was returned was:

[Warning] Using a password on the command line interface can be insecure. mysqladmin: connect to server at 'localhost' failed error: Can't connect to local MySQL server through socket '/tmp/mysql.sock (2)' Check that mysqld is running and that the socket: '/tmp/mysql.sock' exists!

From here I attempted to find the "usr" folder (hidden files are showing) or even anything that closely resembles MySQL anywhere on my computer and got nothing except for installation .dmg files.

I know that MySQL was installed because it is now able to be started and stopped in the System Preferences pane, but clearly none of my commands are working and I keep getting this error no matter what I do:

mysql: command not found

Can someone give me some clue as to what I am missing? I've become fairly desperate and can't figure out what I am doing wrong. I am running El Capitan.


回答1:


Well, if you're saying that MySQL is running, you can try looking for it via terminal command like this:

ps aux | grep mysql

which should give something like

12345 ... 5 Apr16 9:09.32 /usr/local/Cellar/mysql/5.6.17/bin/mysqld --basedir=/usr/local/Cellar/mysql/5.6.17 --datadir=/usr/local/var/mysql --bind-address=127.0.0.1 

so basedir and datadir is probably the most valuable outputs here (please note that your path most likely will be different).

On top of it, in order to get mysql command running through terminal you have two options

  1. Create simulink from mysql's basedir into your /usr/local/bin directory

    ln -s /usr/local/Cellar/mysql/5.6.17/bin/mysql /usr/local/bin/mysql

  2. Add mysql's basedir/bin to your path (need to add this to your ~/.bashrc to make it persistent)

    export PATH=/usr/local/Cellar/mysql/5.6.17/bin/:$PATH

    New terminal tab is required for these changes to catch up.

Cheers.



来源:https://stackoverflow.com/questions/36610619/mysql-is-not-found-anywhere-on-computer

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!