本Ubuntu中的IP地址为:192.168.121.131

Navicat版本:16

安装mysql       sudo apt install mysql-server            (默认为5.7版本)

        安错了想删除,可以参考  Ubuntu彻底卸载MySQL - 北漂的尘埃 - 博客园 (cnblogs.com)

一、检验是否安装mysql成功:

sudo netstat -tap | grep mysql

二、配置文件一般在/etc/mysql/my.cnf或者/etc/my.cnf或者/etc/mysql/mysql.conf.d/mysqld.cnf,我的mysql配置文件就在mysqld.cnf中

        修改文件内容,将bind-address = 127.0.0.1在前面加上#注释掉

三、主要命令

1、重启mysql

service mysql restart

2、免密连接Mysql
mysql -uroot -p

3、看当前所有数据库:

        show databases;

进入mysql数据库:

        use mysql;

        之后才可进行下列操作,否则报错
 

查看user表中的数据:

        select Host, User from user;

修改user表中的Host:

        update user set Host='%' where User='root';

重置密码
        update mysql.user set authentication_string=password('密码') where user='root' ;

        或

        update mysql.user set password=password('密码') where user='root' and host='localhost';

刷新

        flush privileges;

退出
        quit

Navicat连接Mysql

        先Navicat连通SSH服务器(22端口),在SSH服务器连通数据库(3306端口)

1、主机IP为ubuntu的IP,端口22,用户名及密码为Ubuntu账号密码

 2、主机IP为ubuntu的IP,端口22,用户名及密码为mysql中所设置的账号密码

 此两者密码可能有所不同,需区分开。

Logo

北京人形旗下天工造物具身智能开源社区,聚焦具身天工与慧思开物两大平台

更多推荐