mac安装mysql
安装
brew install mysql@5.6
启动
brew services start mysql
安装后提示信息
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.25_1: 300 files, 289.3MB
==> Caveats
==> mysql
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
安装后提示信息
select host,user,authentication_string from mysql.user;
host: 允许用户登录的ip‘位置'%表示可以远程;
user:当前数据库的用户名;
authentication_string: 用户密码(后面有提到此字段)
如果authentication_string下面有值则清空
use mysql;
update user set authentication_string='' where user='root'
设置root密码
ALTER user 'root'@'localhost' IDENTIFIED BY 'root'
连接mysql
mysql -uroot -p