How to set up password-free login in MySQL

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

Insert picture description here

or

Add user/password:
Insert picture description here
log in to the database

mysql --defaults-file=.my.cnf

Guess you like

Origin blog.csdn.net/ichen820/article/details/115124677