Mysql的一些常用命令

1.开启服务器(Mca命令行)

sudo /usr/local/mysql/supporting-files/mysql.server start

2.进入mysql

mysql -uroot -p

3.当Mca打不开mysql服务器时,可能有几种原因:

http://stackoverflow.com/questions/4963171/mysql-server-startup-error-the-server-quit-without-updating-pid-file

(1)查看错误日志:/usr/local/mysql-5.7.16-osx10.11-x86_64/data/SihuideMacBook.local.err

2017-02-02T15:35:19.497105Z 0 [Note] InnoDB: Check that you do not already have another mysqld process using the same InnoDB data or log files.
2017-02-02T15:35:20.498583Z 0 [ERROR] InnoDB: Unable to lock ./ibdata1 error: 35
2017-02-02T15:35:20.498626Z 0 [Note] InnoDB: Check that you do not already have another mysqld process using the same InnoDB data or log files.
2017-02-02T15:35:21.500087Z 0 [ERROR] InnoDB: Unable to lock ./ibdata1 error: 35
2017-02-02T15:35:21.500130Z 0 [Note] InnoDB: Check that you do not already have another mysqld process using the same InnoDB data or log files.
2017-02-02T15:35:22.501613Z 0 [ERROR] InnoDB: Unable to lock ./ibdata1 error: 35
2017-02-02T15:35:22.501657Z 0 [Note] InnoDB: Check that you do not already have another mysqld process using the same InnoDB data or log files.
2017-02-02T15:35:23.503139Z 0 [ERROR] InnoDB: Unable to lock ./ibdata1 error: 35
2017-02-02T15:35:23.503182Z 0 [Note] InnoDB: Check that you do not already have another mysqld process using the same InnoDB data or log files.
2017-02-02T15:35:23.503193Z 0 [Note] InnoDB: Unable to open the first data file
2017-02-02T15:35:23.503227Z 0 [ERROR] InnoDB: Operating system error number 35 in a file operation.
2017-02-02T15:35:23.503255Z 0 [ERROR] InnoDB: Error number 35 means 'Resource temporarily unavailable'
2017-02-02T15:35:23.503267Z 0 [Note] InnoDB: Some operating system error numbers are described at http://dev.mysql.com/doc/refman/5.7/en/operating-system-error-codes.html
2017-02-02T15:35:23.503281Z 0 [ERROR] InnoDB: Cannot open datafile './ibdata1'
2017-02-02T15:35:23.503297Z 0 [ERROR] InnoDB: Could not open or create the system tablespace. If you tried to add new data files to the system tablespace, and it failed here, you should now edit innodb_data_file_path in my.cnf back to what it was, and remove the new ibdata files InnoDB created in this failed attempt. InnoDB only wrote those files full of zeros, but did not yet use them in any way. But be careful: do not remove old data files which contain your precious data!
2017-02-02T15:35:23.503312Z 0 [ERROR] InnoDB: Plugin initialization aborted with error Cannot open a file
2017-02-02T15:35:23.819889Z 0 [ERROR] Plugin 'InnoDB' init function returned error.
2017-02-02T15:35:23.819935Z 0 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed.
2017-02-02T15:35:23.819951Z 0 [ERROR] Failed to initialize plugins.
2017-02-02T15:35:23.819959Z 0 [ERROR] Aborting

2017-02-02T15:35:23.819985Z 0 [Note] Binlog end
2017-02-02T15:35:23.820097Z 0 [Note] Shutting down plugin 'CSV'
2017-02-02T15:35:23.820667Z 0 [Note] /usr/local/mysql/bin/mysqld: Shutdown complete

2017-02-02T15:35:23.6NZ mysqld_safe mysqld from pid file /usr/local/mysql/data/SihuideMacBook.local.pid ended

看第一行,似乎是已有mysql进程在使用

(2)在命令台中输入:ps -ef | grep mysql

就会显示正在运行的mysql进程(四位数的为进程号码),接着用命令:sudo kill -9 进程号码,就可以关闭进程。

(3)重启mysql服务器:sudo /usr/local/mysql/support-files/mysql.server start。发现mysql服务器可以打开了。

 

posted on 2017-02-03 13:49  Sihui  阅读(478)  评论(0编辑  收藏  举报