MySQL configuration files /etc/my.cnf and ~/.my.cnf
Start MySQL on Mac by default
Use mysql -uroot -p and enter the password to log in to mysql
Now I have passed the following configuration, as long as I directly enter mysql to log in (no need to enter mysql password
The specific configuration is as follows:
Create a new ~/.my.cnf and add in ~/.my.cnf
[mysql]
user=用户名
password=密码
Note: If you use the sudo vim /etc/my.cnf command to add the above content to my.cnf, it is also possible, but use sudo to enter the computer password every time
or
Add user/password:
log in to the database
mysql --defaults-file=.my.cnf