MySQL 的日常使用

*nix os 下配置文件一般存放位置

default options are read from the following files in the given order: /etc/my.cnf, /etc/mysql/my.cnf, /usr/local/etc/my.cnf, ~/.my.cnf

默認設置按一下順序讀取:

/etc/my.cnf, /etc/mysql/my.cnf, /usr/local/etc/my.cnf, ~/.my.cnf


Ubuntu 下的啟動,停止與重啟

啟動方式:

  • 方式一:sudo /etc/init.d/mysql start

  • 方式二:sudo start mysql

  • 方式三:sudo service mysql start

停止mysql:

  • 方式一:sudo /etc/init.d/mysql stop

  • 方式二:sudo stop mysql

  • 方式三:sudo service mysql stop

重啟mysql:

  • 方式一:sudo/etc/init.d/mysql restart

  • 方式二:sudo restart mysql

  • 方式三:sudo service mysql restart

Mac 下的啟動,停止與重啟

這里記錄通過 homebrew 安裝的操作

  • 啟動:?mysql.server start

  • 停止:?mysql.server stop

  • 重啟:?mysql.server restart 或者 reload 或者 force-reload


### 權限管理?查看mysql狀態

  • 方式一:service mysql status?(輸出類似mysql start/running, process 810)

  • 方式二:登錄mysql client, 執行命令:show status;

  • 方式三:Mac 如果是通過 homebrew 安裝的,則可以直接使用?mysql.server status查看

增加用戶及權限

GRANT?ALL?ON?*.*?TO?'username'@'hostname'?IDENTIFIED?BY?'username'?WITH?GRANT?OPTION;?  #?然后刷新權限?flush?privileges;

刪除用戶權限

REVOKE?ALL?ON?*.*?FROM?'username'@'hostname';?#?然后刷新權限?flush?privileges;

以上就是MySQL 的日常使用的內容,更多相關內容請關注PHP中文網(www.php.cn)!

? 版權聲明
THE END
喜歡就支持一下吧
點贊8 分享