Ubuntu系统安装数据库(MySQL)8.0版本并授权Navicat进行远程登录

[root@zhnagguolong-virtual-machine:/#] sudo apt-get install mysql-server #安装mysql

[root@zhnagguolong-virtual-machine:/#] systemctl status mysql        #查看mysql的状态
● mysql.service - MySQL Community Server
     Loaded: loaded (/lib/systemd/system/mysql.service; enabled; vendor preset: enabled)
     Active: active (running) since Sun 2022-10-02 23:55:59 CST; 2min 8s ago
    Process: 6313 ExecStartPre=/usr/share/mysql/mysql-systemd-start pre (code=exited, status=0/SUCCESS)
   Main PID: 6321 (mysqld)
     Status: "Server is operational"
      Tasks: 38 (limit: 4584)
     Memory: 361.7M
        CPU: 2.361s
     CGroup: /system.slice/mysql.service
             └─6321 /usr/sbin/mysqld
[root@zhnagguolong-virtual-machine:/#] sudo mysql           #进入数据库
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 8
Server version: 8.0.30-0ubuntu0.22.04.1 (Ubuntu)

Copyright (c) 2000, 2022, Oracle and/or its affiliates.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> use mysql;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
mysql> select host,user from user;
+-----------+------------------+
| host      | user             |
+-----------+------------------+
| localhost | debian-sys-maint |
| localhost | mysql.infoschema |
| localhost | mysql.session    |
| localhost | mysql.sys        |
| localhost | root             |
+-----------+------------------+
5 rows in set (0.00 sec)

mysql>update user set host='%' where user='root';
Query OK, 1 row affected (0.00 sec)
Rows matched: 1  Changed: 1  Warnings: 0

mysql> select host,user from user;
+-----------+------------------+
| host      | user             |
+-----------+------------------+
| %         | root             |
| localhost | debian-sys-maint |
| localhost | mysql.infoschema |
| localhost | mysql.session    |
| localhost | mysql.sys        |
+-----------+------------------+
5 rows in set (0.01 sec)

mysql>FLUSH PRIVILEGES;                         #刷新权限

mysql> alter user 'root'@'%' identified with mysql_native_password by '123456'; #修改mysql的密码,在这里密码假设设为123456,可以根据自己的想法修改
Query OK, 0 rows affected (0.00 sec)

mysql> grant all privileges on *.* to 'root'@'%';
Query OK, 0 rows affected (0.00 sec)

mysql> FLUSH PRIVILEGES;                        #刷新
Query OK, 0 rows affected (0.00 sec)

mysql>exit                                      #退出数据库

[root@zhnagguolong-virtual-machine:/#] mysql -u root -p     #修改完密码后,重启进入数据库

mysql> use mysql;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Database changed

mysql> FLUSH PRIVILEGES;                        #刷新
 
mysql>exit                                      #退出数据库

[root@zhnagguolong-virtual-machine:/#] vim etc/mysql/mysql.conf.d/mysqld.cnf #修改配置文件
找到这一行:bind-address            = 127.0.0.1
         mysqlx-bind-address     = 127.0.0.1
将其修改为:bind-address            = 0.0.0.0
         mysqlx-bind-address     = 0.0.0.0
         
[root@zhnagguolong-virtual-machine:/#] service  mysql restart  #重启mysql

[root@zhnagguolong-virtual-machine:/#] ifconfig                #查看Ubuntu系统ip地址

[root@zhnagguolong-virtual-machine:/#] telnet ip地址 3306      #远程登录
Trying ip...
Connected to ip.
Escape character is '^]'.
[
8.0.30-0ubuntu0.22.04.1
tGiC<{!�q6fzn6>=caching_sha2_password2#08S01Got timeout reading communication packetsConnection closed by foreign host.
代表已经连接成功

1993447-20200517091447142-1252588682.png

  • 15
    点赞
  • 10
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 4
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

御风者hexo

请小哥我喝一瓶水吧,谢谢大家了

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值