標籤:who res run wpa 關閉 輸入 auth har ica
brew install mysql
2. 在 /usr/local/etc/ 下建立或修改 my.cnf,樣本:
[client]
port = 3306
socket = /tmp/mysql.sock
default-character-set = utf8
[mysqld]
collation-server = utf8_unicode_ci
character-set-server = utf8
init-connect =‘SET NAMES utf8‘
max_allowed_packet = 64M
bind-address = 127.0.0.1
port = 3306
socket = /tmp/mysql.sock
innodb_file_per_table=1
[mysqld_safe]
timezone = ‘+0:00‘
3. 贊安裝完 mysql 後,他會提示你 init database,並提供下面這兩句讓你執行,很可能你沒執行這兩句
$ unset TMPDIR
$ mysql_install_db --verbose --user=`whoami` --basedir="$(brew --prefix mysql)" --datadir=/usr/local/var/mysql --tmpdir=/tmp
4. 然後就可以指向 mysql.server start 來啟動了,為了安全,你還可以執行安全設定嚮導,根據提示一步一步配置
1.1 開啟系統喜好設定,如果你的電腦已經安裝MySQL,會在下面有一個mysql的按鈕。點進去關閉mysql服務。
關閉myql
1.2 開啟一個終端,輸入一下命令
$ cd /usr/local/mysql/bin
$ sudo su
1
2
1
2
然後便可以看到終端命令變成這個開頭: sh-3.2#
輸入一下命令
sh-3.2#./mysqld_safe --skip-grant-tables &
1
1
之後邊可以以安全模式進入資料庫了。
1.3 現在開啟一個新的終端
輸入以下命令:
mysql -u -root
SET PASSWORD FOR ‘root‘@‘localhost‘ = PASSWORD(‘newpass‘);
update user set authentication_string=password(‘root‘) where Host=‘localhost‘ and User=‘root‘;
$ mysql_secure_installation
e‘ve installed your MySQL database without a root password. To secure it run:
mysql_secure_installation
MySQL is configured to only allow connections from localhost by default
To connect run:
mysql -uroot
To have launchd start mysql now and restart at login:
brew services start mysql
Or, if you don‘t want/need a background service you can just run:
mysql.server start
mac安裝mysql