[MySQL实践] 实践记录

[MySQL实践] 实践记录

版权2019.5.17更新

MySQL

MySQL各版本区别

 一、选择的版本

1. MySQL Community Server 社区版本,开源免费,但不提供官方技术支持。
2. MySQL Enterprise Edition 企业版本,需付费,可以试用30天。
3. MySQL Cluster 集群版,开源免费。可将几个MySQL Server封装成一个Server。
4. MySQL Cluster CGE 高级集群版,需付费。
5. MySQL Workbench(GUI TOOL)一款专为MySQL设计的ER/数据库建模工具。它是著名的数据库设计工具DBDesigner4的继任者。MySQL Workbench又分为两个版本,分别是社区版(MySQL Workbench OSS)、商用版(MySQL Workbench SE)。

macOS系统brew安装:

(base) 
tp0829 at MacBook-Pro-TP in ~
$ brew install mysql
==> Downloading https://homebrew.bintray.com/bottles/mysql-8.0.16.mojave.bottle.tar.gz
==> Downloading from https://akamai.bintray.com/65/65e6629740ca75ceaae575b4cc68f2cf133619d08cdcd4cb2
######################################################################## 100.0%
==> Pouring mysql-8.0.16.mojave.bottle.tar.gz
==> /usr/local/Cellar/mysql/8.0.16/bin/mysqld --initialize-insecure --user=tp0829 --basedir=/usr/loc
==> Caveats
We'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
==> Summary
🍺  /usr/local/Cellar/mysql/8.0.16: 275 files, 269.8MB
==> `brew cleanup` has not been run in 30 days, running now...
Removing: /usr/local/Cellar/gdbm/1.14.1_1... (20 files, 555.7KB)
Removing: /usr/local/Cellar/gdbm/1.16... (19 files, 578.5KB)
Removing: /usr/local/Cellar/openssl/1.0.2q... (1,794 files, 12.1MB)
Pruned 0 symbolic links and 5 directories from /usr/local

(base) 
tp0829 at MacBook-Pro-TP in ~
$ 

(base) 
tp0829 at MacBook-Pro-TP in ~
$ mysql_secure_installation

Securing the MySQL server deployment.

Enter password for user root: 
Error: Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)
(base) 
tp0829 at MacBook-Pro-TP in ~
$ mysql -uroot
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)
(base) 
tp0829 at MacBook-Pro-TP in ~
$ brew services start mysql
==> Successfully started `mysql` (label: homebrew.mxcl.mysql)
(base) 
tp0829 at MacBook-Pro-TP in ~
$ mysql_secure_installation

Securing the MySQL server deployment.

Connecting to MySQL using a blank password.

VALIDATE PASSWORD COMPONENT can be used to test passwords
and improve security. It checks the strength of password
and allows the users to set only those passwords which are
secure enough. Would you like to setup VALIDATE PASSWORD component?

Press y|Y for Yes, any other key for No: n
Please set the password for root here.

New password: #123456

Re-enter new password: 
By default, a MySQL installation has an anonymous user,
allowing anyone to log into MySQL without having to have
a user account created for them. 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? (Press y|Y for Yes, any other key for No) : 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? (Press y|Y for Yes, any other key for No) : n

 ... skipping.
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? (Press y|Y for Yes, any other key for No) : 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? (Press y|Y for Yes, any other key for No) : y
Success.

All done! 
(base) 
tp0829 at MacBook-Pro-TP in ~
$ 


Homebrew Services

参考:

https://www.jianshu.com/p/6c3b26490861

https://github.com/Homebrew/homebrew-services

https://www.jianshu.com/p/90939b788004

Homebrew Services
Integrates Homebrew formulae with macOS' launchctl manager.
macOS使用launchctl命令加载开机自动运行的服务,brew service可以简化lauchctl的操作。

Install
brew services is automatically installed when run.
在使用时会自动安装

Usage
Start
Start the MySQL service at login with:

brew services start mysql
Start the Dnsmasq service at boot with:

sudo brew services start dnsmasq
Start all available services with:

brew services start --all
Run
Run the MySQL service but don't start it at login (nor boot) with:

brew services run mysql
Stop
Stop the MySQL service with:

brew services stop mysql
Restart
Restart the MySQL service with:

brew services restart mysql
List
List all services managed by brew services with:

brew services list
Cleanup
Remove all unused services with:

brew services cleanup

|版权声明:除特别注明外,本博客所有文章均为博主T.P原创,转载请注明出处:https://www.cnblogs.com/tp0829/p/10801245.html

posted @ 2019-05-19 23:31  T.P  阅读(205)  评论(0编辑  收藏  举报