MySQL修改端口

「爱情、让人受尽委屈。」 2023-01-13 08:57 198阅读 0赞

文章目录

  • 一、mysql 查看端口
  • 二、netstat 查看端口
  • 三、修改my.cnf
  • 四、重启mysql
  • 五、netstat 再次查看

一、mysql 查看端口

  1. [root@localhost ~]# mysql -u root -p
  2. Enter password:
  3. Welcome to the MySQL monitor. Commands end with ; or \g.
  4. Your MySQL connection id is 723
  5. Server version: 5.7.33 MySQL Community Server (GPL)
  6. Copyright (c) 2000, 2021, Oracle and/or its affiliates.
  7. Oracle is a registered trademark of Oracle Corporation and/or its
  8. affiliates. Other names may be trademarks of their respective
  9. owners.
  10. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
  11. mysql> show global variables like 'port';
  12. +---------------+-------+
  13. | Variable_name | Value |
  14. +---------------+-------+
  15. | port | 3306 |
  16. +---------------+-------+
  17. 1 row in set (0.01 sec)
  18. mysql> exit
  19. Bye

二、netstat 查看端口

  1. [root@localhost ~]# netstat -nplt
  2. Active Internet connections (only servers)
  3. Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
  4. tcp6 0 0 :::3306 :::* LISTEN 3115/mysqld
  5. tcp6 0 0 :::6379 :::* LISTEN 1852/redis-server *

三、修改my.cnf

  1. vim /etc/my.cnf

在这里插入图片描述

四、重启mysql

  1. systemctl restart mysqld

五、netstat 再次查看

  1. [root@localhost ~]# netstat -nplt
  2. Active Internet connections (only servers)
  3. Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
  4. tcp6 0 0 :::19306 :::* LISTEN 25953/mysqld
  5. tcp6 0 0 :::6379 :::* LISTEN 1852/redis-server *

觉得好,就一键三连呗(点赞+收藏+关注)

发表评论

表情:
评论列表 (有 0 条评论,198人围观)

还没有评论,来说两句吧...

相关阅读

    相关 mysql修改默认端口

    \\\mysql修改默认端口\\\ 找到MYSQL安装目录的my.ini,用编辑器打开(本次使用的notepad++),直接Ctrl+F,搜索port,如图所示。 ![Ce