➜ ~ sudo mysql.server status
Password:
ERROR! MySQL is not running
登入後複製
啟動MYSQL服務
➜ ~ sudo mysql.server start
Starting MySQL
.Logging to '/usr/local/mysql/data/mj.local.err'.
SUCCESS!
登入後複製
登入後複製
停止MYSQL服務
➜ ~ sudo mysql.server stop
Shutting down MySQL
. SUCCESS!
登入後複製
重啟MYSQL服務
➜ ~ sudo mysql.server restart
ERROR! MySQL server PID file could not be found!
Starting MySQL
. SUCCESS!
登入後複製
啟動
##第一步,在終端介面下輸入
➜ ~ sudo mysql.server start
Starting MySQL
.Logging to '/usr/local/mysql/data/mj.local.err'.
SUCCESS!
登入後複製
登入後複製
第二步,啟動MYSQL服務,啟動成功後繼續輸入
➜ ~ mysql -u root -p
登入後複製
第三步,直接回車,進入資料庫,看到以下歡迎介面
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.6.41 MySQL Community Server (GPL)
Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql>
登入後複製
備註:預設安裝成功後沒有初始密碼,所以密碼不用輸入,直接回車即可。
初始化設定
設定初始密碼,進入mysql資料庫之後執行下面的語句,設定目前root使用者的密碼為root
➜ ~ mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.6.41 MySQL Community Server (GPL)
Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> set password = password('root');
Query OK, 0 rows affected (0.01 sec)
mysql>
➜ ~ mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 4
Server version: 5.6.41 MySQL Community Server (GPL)
Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> show variables like '%char%';
+--------------------------+-----------------------------------------------------------+
| Variable_name | Value |
+--------------------------+-----------------------------------------------------------+
| character_set_client | utf8 |
| character_set_connection | utf8 |
| character_set_database | latin1 |
| character_set_filesystem | binary |
| character_set_results | utf8 |
| character_set_server | latin1 |
| character_set_system | utf8 |
| character_sets_dir | /usr/local/mysql-5.6.41-macos10.13-x86_64/share/charsets/ |
+--------------------------+-----------------------------------------------------------+
8 rows in set (0.01 sec)
mysql>