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

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

PHP中文网
PHP中文网

认证0级讲师

reply all(6)
小葫芦

This is my latest and always recommended method:
1. Installation: sunyichaodeMacBook-Pro:~ sunyichao$ brew install mysql
2. Start mysql: mysql.server start
2. Use mysql configuration script: /usr/local/opt/mysql/bin/mysql_secure_installation //mysql 提供的配置向导
After starting this script, you can perform initialization settings according to the following command prompt

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 (Installation)
  2. Add and modify mysql configuration

    mysqld --help --verbose | more (View help, press space to scroll down)

    You will see this line at the beginning (indicating the default reading order of the configuration file)

    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

    Usually there are no configuration files in these locations, so you have to create one yourself

    ls $(brew --prefix mysql)/support-files/my-* (Use this to find the sample.cnf)
    cp /usr/local/opt/mysql/support-files/my-default.cnf /etc/my.cnf (Copy to the first default reading directory)

    Modify my.cnf as needed

  3. brew services start mysql (start)

  4. brew services stop mysql (stop)
洪涛

Isn’t it a little late to answer now?
I also installed mysql on mac a few days ago.

There are differences between mysql database versions before and after 5.7.5.
Previous versions would require a password during installation.
The 5.7.6 version will randomly generate a password during installation. When installing using the graphical interface, the password will be displayed. If installed using the brew install mysql command, the password will not be displayed.
At this time, you have to use other methods to solve the problem, otherwise an error will be reported:

The solution is shown on the official website:
http://dev.mysql.com/doc/refman/5.7/en/r...

To save trouble, you can install it directly using the graphical interface, and then use ALTER USER to change the password.

Ty80

When I use brew to install mysql, why can it be used directly without any configuration (except configuring the username and password)?

大家讲道理

@子晓_believe, after I used it, I found that the local host name was changed to bogon. What happened?

小葫芦

Password requirements have become stricter after 5.7.11. You can refer to the following method to configure
MySQL configuration after installation

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template