Git Bash mysql blank

谁都会走 提交于 2019-12-31 08:01:32

问题


I've installed Git (bash?) from www.git-scm.com I also have a working installation of MySQL. I'm using windows 8.1. The path to my mysql bin directory IS in my path environment variable, and the mysql service IS running.

If i open cmd.exe and type in mysql -u root then it logs me in successfully, I get the "welcome to mysql monitor" message, and i can start typing sql away.

However in Git bash, if I type in mysql -u root then it just starts a new blank link and doesn't do anything.

If i type in mysql -? then i still get the mysql help information. If i type in mysql start, I get the Access denied for user ''@'localhost' to database 'start'.

How can I access mysql properly in git bash?

Please see my crude image explaining my situation below:


回答1:


I had the same problem with git bash and mysql, and solution to this is to use

winpty mysql -u root

I guess this is because you are running mysql for windows, using unix environment, and as far as I know winpty should be used for running windows applications in the git bash (not 100% sure, maybe someone can confirm).




回答2:


Create a shortcut in Windows Desktop with this destination:

"C:\Program Files\Git\usr\bin\mintty.exe" -e "C:\Program Files\Git\usr\bin\winpty.exe" "C:\Program Files (x86)\MariaDB 10.1\bin\mysql.exe" -uroot -p




回答3:


A Quick fix for others facing that issue too :

You can create a .bash_profile to config git bash, to always use winpty by default :

cd ~ && echo "alias mysql=\"winpty mysql\"" > .bash_profile

if you already have a .bash_profile in your user folder use this command instead:

cd ~ && echo "alias mysql=\"winpty mysql\"" >> .bash_profile


来源:https://stackoverflow.com/questions/32620670/git-bash-mysql-blank

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