macos - 在Mac OS Lion上从命令行启动MySQL服务器
我为我的Mac安装了mySQL。 除了使用系统首选项中安装的mySQL.prefPane工具启动SQL服务器之外,我想知道从命令行启动的指令。我这样做:
后
苏根
我通过命令行启动mySQL服务器,它产生如下错误:
sh-3.2#/ usr / local / mysql / bin / mysqld
111028 16:57:43 [警告]设置lower_case_table_names = 2因为 /usr/local/mysql-5.5.17-osx10.6-x86_64/data/的文件系统是大小写 麻木不仁
111028 16:57:43 [错误]致命错误:请阅读“安全”部分 手册,了解如何以root身份运行mysqld!
111028 16:57:43 [错误]中止
111028 16:57:43 [注意] / usr / local / mysql / bin / mysqld:关闭完成
请帮我!
编辑:
原因在于:[http://dev.mysql.com/doc/refman/5.5/en/changing-mysql-user.html]
下面的xdazz答案中描述了一个解决方案。
12个解决方案
179 votes
试试/usr/local/mysql/bin/mysqld_safe
例:
shell> sudo /usr/local/mysql/bin/mysqld_safe
(Enter your password, if necessary)
(Press Control-Z)
shell> bg
(Press Control-D or enter "exit" to exit the shell)
您还可以将这些添加到bash启动脚本中:
export MYSQL_HOME=/usr/local/mysql
alias start_mysql='sudo $MYSQL_HOME/bin/mysqld_safe &'
alias stop_mysql='sudo $MYSQL_HOME/bin/mysqladmin shutdown'
xdazz answered 2019-04-29T18:33:48Z
149 votes
只是:
mysql.server restart
mysql.server restart
mysql.server restart
user2792249 answered 2019-04-29T18:34:17Z
132 votes
我也喜欢这些别名...但是,我开始使用MySQLCOM时遇到了问题......它无声地失败了...我的解决方法类似于其他...〜/ .bash_aliases
alias mysqlstart='sudo /usr/local/mysql/support-files/mysql.server start'
alias mysqlstop='sudo /usr/local/mysql/support-files/mysql.server stop'
Eddie B answered 2019-04-29T18:34:41Z
78 votes
正如这篇有用的文章所述:在OS X上从命令行启动/停止MySQL:
sudo /usr/local/mysql/support-files/mysql.server start
sudo /usr/local/mysql/support-files/mysql.server stop
在Linux上从命令行启动/停止:
/etc/init.d/mysqld start
/etc/init.d/mysqld stop
/etc/init.d/mysqld restart
一些Linux风格也提供服务命令
# service mysqld start
# service mysqld stop
# service mysqld restart
要么
# service mysql start
# service mysql stop
# service mysql restart
David answered 2019-04-29T18:35:19Z
66 votes
如果你用自制软件安装它,二进制文件就会像
/usr/local/Cellar/mysql/5.6.10/bin/mysqld
这意味着你可以用它来启动它
/usr/local/Cellar/mysql/5.6.10/support-files/mysql.server start
并停止它
/usr/local/Cellar/mysql/5.6.10/support-files/mysql.server stop
编辑:正如Jacob Raccuia所说,请确保在路径中放置适当版本的MySQL。
Alex K answered 2019-04-29T18:36:02Z
31 votes
sudo /Library/StartupItems/MySQLCOM/MySQLCOM start
sudo /Library/StartupItems/MySQLCOM/MySQLCOM stop
在.bash_profile中创建别名
alias start_mysql="/Library/StartupItems/MySQLCOM/MySQLCOM start"
alias stop_mysql="/Library/StartupItems/MySQLCOM/MySQLCOM stop"
如果您尝试以root用户身份运行安全模式
sudo ./bin/mysqld_safe
如果您仍然遇到问题,建议阅读:mac os 10.6.5中的mysql5.58 unstart服务器
Dennis answered 2019-04-29T18:36:39Z
27 votes
也许你的mysql-server没有启动
你可以试试
/usr/local/bin/mysql.server启动
42wolf answered 2019-04-29T18:37:16Z
9 votes
如果它与自制软件一起安装,请尝试在终端中键入mysql.server,这应该是它。它可执行的AFAIK将在/usr/local/bin/mysql.server下。
如果没有,你可以随时运行“locate mysql.server”,它将告诉你在哪里可以找到这样的文件。
Nevio Vesić answered 2019-04-29T18:37:46Z
5 votes
如果您通过Homebrew安装了MySQL,这些命令将帮助您:
# For starting
launchctl load ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist
# For stoping
launchctl unload ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist
Mario Uher answered 2019-04-29T18:38:10Z
4 votes
我的MySQL是通过OSX El Capitan上的自制程序安装的。 是什么修复它运行
sudo chown -R $(whoami):admin /usr/local
这表明我跑了
sudo chown -R $(whoami):admin /usr/local
然后:
brew update
mysql.server start
mysql现在正在运行
Merhawi Fissehaye answered 2019-04-29T18:38:57Z
3 votes
对我来说,这个解决方案适用于Mac Sierra OS:
sudo /usr/local/bin/mysql.server start
Starting MySQL
SUCCESS!
shacharsol answered 2019-04-29T18:39:21Z
0 votes
111028 16:57:43 [ERROR] Fatal error: Please read "Security" section of the manual to find out how to run mysqld as root!
您是否为mysql安装设置了root密码? 这与您的sudo root密码不同。 试试/usr/local/mysql/bin/mysql_secure_installation
Hoppo answered 2019-04-29T18:39:46Z