linux下mysql安装、授权、创建用户、连接navicat、连接entity
1.linux下安装mysql:
sudo apt-get update sudo apt-get install mysql-server sudo systemctl start mysql sudo mysql_secure_installation #这一步不是必须的,甚至有害的
2.修改地址绑定:
绑定地址访问:
#修改配置文件,也可以用vi、gedit之类
pluma /etc/mysql/mysql.conf.d/mysqld.cnf
#修改bind-address=127.0.0.1为0.0.0.0
bind-address = 0.0.0.0
mysqlx-bind-address = 0.0.0.0
#然后重启mysql
systemctl restart mysql
3.授权
首先登录mysql客户端:mysql -uroot 初始化没有密码。
mysql -uroot
然后授权:
use mysql; update user set host='%' where user='root'; flush privileges;
#GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' WITH GRANT OPTION;
grant all privileges on *.* to 'root'@'%';
修改root用户的密码:
ALTER USER 'root'@'%' IDENTIFIED BY '666666';
查看:
select user ,host from user;
+------------------+-----------+
| user | host |
+------------------+-----------+
| root | % |
| mysql.sys | localhost|
+------------------+-----------+
4.创建用户
4.1登录root账号
1 | mysql -uroot -p666666 --uroot中root为登录用户, -p666666中666666为登录密码 |
4.2创建用户
1 | create user test@ '%' identified by '666666' ;<br>grant all privileges on *.* to 'test' @ '%' with grant option; |
5.查看检索mysqluser
1 | select user ,host from user |
5.navicat连接
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】凌霞软件回馈社区,博客园 & 1Panel & Halo 联合会员上线
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】博客园社区专享云产品让利特惠,阿里云新客6.5折上折
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· Deepseek官网太卡,教你白嫖阿里云的Deepseek-R1满血版
· 2分钟学会 DeepSeek API,竟然比官方更好用!
· .NET 使用 DeepSeek R1 开发智能 AI 客户端
· DeepSeek本地性能调优
· 一文掌握DeepSeek本地部署+Page Assist浏览器插件+C#接口调用+局域网访问!全攻略