如何使用 xampp 从 mac 终端访问 mysql?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/13892904/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How do i access mysql from mac terminal, using xampp?
提问by newestUser
I am trying to access mysql from my mac's terminal.
我正在尝试从我的 mac 终端访问 mysql。
I have tried just typing
我试过只打字
mysql -u root -p
mysql -u 根 -p
(and Enter, but that does not exist..)
(和输入,但不存在..)
This is what i have managed to do/located so far:
这是我迄今为止设法做/定位的:
Williams-iMac:mysql noName$ cd /Applications/xampp/xamppfiles/var/mysql/mysql
Williams-iMac:mysql noName$ ls
Williams-iMac:mysql noName$ cd /Applications/xampp/xamppfiles/var/mysql/mysql
Williams-iMac:mysql noName$ ls
This is what is located there.
这就是位于那里的东西。
columns_priv.MYD help_relation.frm slow_log.CSV
columns_priv.MYI help_topic.MYD slow_log.frm
columns_priv.frm help_topic.MYI tables_priv.MYD
db.MYD help_topic.frm tables_priv.MYI
db.MYI host.MYD tables_priv.frm
db.frm host.MYI time_zone.MYD
event.MYD host.frm time_zone.MYI
event.MYI ndb_binlog_index.MYD time_zone.frm
event.frm ndb_binlog_index.MYI time_zone_leap_second.MYD
func.MYD ndb_binlog_index.frm time_zone_leap_second.MYI
func.MYI plugin.MYD time_zone_leap_second.frm
func.frm plugin.MYI time_zone_name.MYD
general_log.CSM plugin.frm time_zone_name.MYI
general_log.CSV proc.MYD time_zone_name.frm
general_log.frm proc.MYI time_zone_transition.MYD
help_category.MYD proc.frm time_zone_transition.MYI
help_category.MYI procs_priv.MYD time_zone_transition.frm
help_category.frm procs_priv.MYI time_zone_transition_type.MYD
help_keyword.MYD procs_priv.frm time_zone_transition_type.MYI
help_keyword.MYI servers.MYD time_zone_transition_type.frm
help_keyword.frm servers.MYI user.MYD
help_relation.MYD servers.frm user.MYI
help_relation.MYI slow_log.CSM user.frm
But i still don't know how to access the mysql, so that i can create a new database (without doing it i phpmyadmin). I have created a new database in phpmyadmin though, just to try enter:
但我仍然不知道如何访问 mysql,以便我可以创建一个新数据库(我 phpmyadmin 没有这样做)。我在 phpmyadmin 中创建了一个新数据库,只是为了尝试输入:
mysql -u root -p (my_phpmyadmin_created_database)
mysql -u root -p (my_phpmyadmin_created_database)
..but without any success.
..但没有任何成功。
I hope that with all the information i have given about my issue to all of you out there, that someone will help my get by this time-consumimng-heck-of-a-boring-issue! :)
我希望通过我向你们所有人提供的关于我的问题的所有信息,有人会帮助我解决这个耗时的无聊问题!:)
Thanks in advance!
提前致谢!
/W
/W
回答by newestUser
/Applications/xampp/xamppfiles/bin/mysql -u root -p
/Applications/xampp/xamppfiles/bin/mysql -u root -p
Worked like a charm!
像魅力一样工作!
Thanks to user: Wrikken!
感谢用户:Wrikken!
回答by Ricardo
I usually do this to activate phpand mysqlfrom terminal with XAMPP 1.7.3(and probably above) on Mac
我通常这样做是为了在 Mac 上使用 XAMPP 1.7.3(可能更高版本)从终端激活php和mysql
1. Go to Terminal
2. Enter which php: If it says /usr/bin/php, then proceed to 3.
3. Enter sudo nano ~/.bash_profile (or sudo vim ~/.bash_profile if you know how to use it)
4. Then paste this export PATH="/Applications/XAMPP/xamppfiles/bin:$PATH"
5. Ctrl - O then enter to save, then ctrl - X to exit.
6. Type cd ~
7. type . .bash_profile
8. Restart terminal.
9. Enter which php: If you did it right, it should be the same as the path in #4.
回答by Zheng. Cheng
I'm just a new xampp user. I am also trapped by this question. Yes, the right directory is
我只是一个新的 xampp 用户。我也被这个问题困住了。是的,正确的目录是
/Applications/XAMPP/xamppfiles/bin/(the newest xampp is uppercase)
but when you connect to db, you should type
但是当你连接到数据库时,你应该输入
./mysql -u root -p (if there's password),
not input
不输入
mysql -u root -p...
directly, it wordked successfully on my macbook pro.
直接,它在我的 macbook pro 上成功地写了字。
回答by Bhavik Sakhiya
if the xampp is install in your mac book just go the file path of cd /Applications/XAMPP/bin/
如果 xampp 安装在您的 mac book 中,只需转到 cd /Applications/XAMPP/bin/ 的文件路径
./mysql -u root -p
./mysql -u 根 -p
than it will ask for password if set than type else enter
如果设置,它会要求输入密码而不是输入其他类型
mysql is started now !!!!!!!!
mysql现在开始了!!!!!!!!!
回答by Ignacio Ito
sudo /Applications/XAMPP/xamppfiles/bin/mysql.server start
回答by george
I had to use opencommandfor me to work.
我必须使用open命令才能工作。
e.x.
前任
open /App/Applications/xampp/xamppfiles/bin/mysql
打开/App/Applications/xampp/xamppfiles/bin/mysql
回答by vixrenjr
Nice feature on Mac is to open terminal and go to preferences. Hit profiles tab and create a new profile. under shell type the path to MySQL and enter in everything as you would when going the long way. Ex:
Mac 上的一个不错的功能是打开终端并转到首选项。点击配置文件选项卡并创建一个新的配置文件。在 shell 下输入 MySQL 的路径并输入所有内容,就像你在长途跋涉时所做的那样。前任:
/Applications/XAMPP/xamppfiles/bin/mysql --user=root --password=
/Applications/XAMPP/xamppfiles/bin/mysql --user=root --password=
Just add your info on the path above. close the preference window and go to FILE and hit new window. Chose your profile. I named mine MySql. Thats it.
只需在上面的路径中添加您的信息。关闭首选项窗口并转到文件并点击新窗口。选择您的个人资料。我命名我的MySql。就是这样。
回答by user1039695
I used this to access phpmyadmin mysql database though terminal
我用它通过终端访问 phpmyadmin mysql 数据库
/opt/lampp/bin/mysql -uroot -ppassword
then
然后
USE dbname