我在我的Mac上安装了mySQL。除了用mySQL启动SQL服务器。安装在系统首选项中的prepane工具,我想知道从命令行开始的指令。 我的做法如下:

他的root

我通过命令行启动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/”的文件系统为case 不敏感 111028 16:57:43 [ERROR]致命错误:请阅读“安全”部分 如何以root用户运行mysqld ! 111028 16:57:43 [ERROR]中止 111028 16:57:43[注]/usr/local/mysql/bin/mysqld: Shutdown complete


当前回答

也许您的mysql服务器没有启动。

你可以试试

/usr/local/bin/mysql.server start

其他回答

我也喜欢这些别名……然而,我有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' 

尝试/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'

MySql服务器启动错误'服务器退出没有更新PID文件'

如果你从homebrew安装了mysql

从MAC首选项中关闭mysql服务器

ps ax | grep mysql

#kill all the mysql process running
sudo kill -9 pid

which mysql
/usr/local/bin/mysql
Admins-MacBook-Pro:bin username$ sudo mysql.server start

Starting MySQL
. SUCCESS! 

Admins-MacBook-Pro:bin username$ which mysql

/usr/local/bin/mysql

Admins-MacBook-Pro:bin username$ ps ax | grep mysql

54916 s005  S      0:00.02 /bin/sh 
/usr/local/Cellar/mysql@5.7/5.7.27_1/bin/mysqld_safe --datadir=/usr/local/var/mysql --pid-file=/usr/local/var/mysql/Admins-MacBook-Pro.local.pid
55012 s005  S      0:00.40 /usr/local/Cellar/mysql@5.7/5.7.27_1/bin/mysqld --basedir=/usr/local/Cellar/mysql@5.7/5.7.27_1 --datadir=/usr/local/var/mysql --plugin-dir=/usr/local/Cellar/mysql@5.7/5.7.27_1/lib/plugin --user=mysql --log-error=Admins-MacBook-Pro.local.err --pid-file=/usr/local/var/mysql/Admins-MacBook-Pro.local.pid
55081 s005  S+     0:00.00 grep mysql

对我来说,这个解决方案适用于mac Sierra OS:

sudo /usr/local/bin/mysql.server start
Starting MySQL
SUCCESS!

正如这篇有用的文章所述: 在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命令

# service mysqld start 
# service mysqld stop 
# service mysqld restart

or

 # service mysql start 
 # service mysql stop 
 # service mysql restart