macos - homebrew 安装mysql后,如何配置mysql
PHP中文网
PHP中文网 2017-04-17 11:25:18
0
6
674

mac osx 系统(这个无妨)
用homebrew 安装mysql
但是不会配置,网上各有各的说法,求一个用过,懂行的,教一下,

PHP中文网
PHP中文网

认证0级讲师

全部回覆(6)
小葫芦

這個是我最新並且一直推崇的方法:
1、安裝:sunyichaodeMacBook-Pro:~ sunyichao$ brew install mysql
2、開啟mysql:mysql.server start
2、使用mysql的配置腳本:/usr/local/opt/mysql/bin/mysql_secure_installation //mysql 提供的配置向导
啟動這個腳本後,即可依照下列指令提示進行初始化設定

sunyichaodeMacBook-Pro:~ sunyichao$ /usr/local/opt/mysql/bin/mysql_secure_installation   //mysql 提供的配置向导
NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MySQL
      SERVERS IN PRODUCTION USE!  PLEASE READ EACH STEP CAREFULLY!

In order to log into MySQL to secure it, we'll need the current
password for the root user.  If you've just installed MySQL, and
you haven't set the root password yet, the password will be blank,
so you should just press enter here.

Enter current password for root (enter for none): //输入现行root密码,因为初次使用,所以直接回车
OK, successfully used password, moving on...

Setting the root password ensures that nobody can log into the MySQL
root user without the proper authorisation.

Set root password? [Y/n] Y //是否设置root密码
New password:
Re-enter new password:
Password updated successfully!
Reloading privilege tables..
 ... Success!

By default, a MySQL installation has an anonymous user, allowing anyone to log into MySQL without having to have a user account created for This is intended only for testing, and to make the installation go a bit smoother. You should remove them before moving into a production environment.    
Remove anonymous users? [Y/n] Y //是否删除匿名用户
 ... Success!

Normally, root should only be allowed to connect from 'localhost'.This
ensures that someone cannot guess at the root password from the network.

Disallow root login remotely? [Y/n] Y //是否禁止远程登录
 ... Success!

By default, MySQL comes with a database named 'test' that anyone can
access.This is also intended only for testing, and should be removed
before moving into a production environment.

Remove test database and access to it? [Y/n] Y //删除测试数据库,并登录
 Dropping test database...
 ... Success!
 Removing privileges on test database...
 ... Success!

Reloading the privilege tables will ensure that all changes made so far
will take effect immediately.

Reload privilege tables now? [Y/n] Y//重新载入权限表
 ... Success!

All done!  If you've completed all of the above steps, your MySQL
installation should now be secure.

Thanks for using MySQL!

Cleaning up...
sunyichaodeMacBook-Pro:~ sunyichao$
刘奇
  1. brew install mysql (安裝)
  2. 新增修改mysql配置

    mysqld --help --verbose | more (查看幫助, 按空格下翻)

    你會看到開始的這一行(表示設定檔預設讀取順序)

    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

    通常這些位置是沒有設定檔的, 所以要自己建一個

    ls $(brew --prefix mysql)/support-files/my-* (用這個可以找到範例.cnf)
    cp /usr/local/opt/mysql/support-files/my-default.cnf /etc/my.cnf (拷貝到第一個預設讀取目錄)

    按需修改my.cnf

  3. brew services start mysql (啟動)

  4. brew services stop mysql (停止)
洪涛

現在回答是不是有點晚了。
前幾天我也在mac下安裝 mysql.

mysql 資料庫 5.7.5 前後的版本有差異。
以前的版本會在安裝的時候要求輸入密碼。
5.7.6 版本會在安裝的時候隨機產生一個密碼,用圖形界面化安裝的時候會顯示密碼,而用 brew install mysql指令安裝的話,就不會顯示密碼了。
這時候就得用其他辦法就解決,否則會報錯:

解決方法如官網所示:
http://dev.mysql.com/doc/refman/5.7/en/r...

圖省事的話,可以直接用圖形介面安裝,之後再用 ALTER USER 來更改密碼。

Ty80

我用brew安裝mysql的時候為什麼沒設定直接就能用了(除了設定使用者名稱和密碼)?

大家讲道理

@子曉_believe ,我用完之後,發現本地的主機名稱改成了bogon是咋回事兒呀?

小葫芦

5.7.11之後密碼要求更加嚴格了。可以參考下面的方式設定
mysql安裝後配置

熱門教學
更多>
最新下載
更多>
網站特效
網站源碼
網站素材
前端模板