linux mysql 查看默认端口号和修改端口号

linux mysql 查看默认端口号和修改端口号

  1. 如何查看mysql 默认端口号和修改端口号 2015-03-19 17:42:18  
  2.   
  3.   
  4. 1. 登录mysql  
  5.   
  6. [root@test /]# mysql -u root -p  
  7. Enter password:  
  8.   
  9.   
  10. 2. 使用命令show global variables like ‘port’;查看端口号  
  11.   
  12. mysql> show global variables like ‘port’;  
  13. +—————+——-+  
  14. | Variable_name | Value |  
  15. +—————+——-+  
  16. | port | 3306 |  
  17. +—————+——-+  
  18. 1 row in set (0.00 sec)  
  19.   
  20.   
  21. 3. 修改端口,编辑/etc/my.cnf文件,早期版本有可能是my.conf文件名,增加端口参数,并且设定端口,注意该端口未被使用,保存退出。  
  22.   
  23. [root@test etc]# vi my.cnf  
  24. [mysqld]  
  25. port=3506  
  26. datadir=/var/lib/mysql  
  27. socket=/var/lib/mysql/mysql.sock  
  28. user=mysql  
  29. # Disabling symbolic-links is recommended to prevent assorted security risks  
  30. symbolic-links=0  
  31.   
  32. [mysqld_safe]  
  33. log-error=/var/log/mysqld.log  
  34. pid-file=/var/run/mysqld/mysqld.pid  
  35.   
  36. “my.cnf” 11L, 261C written  
  37. [root@test etc]#  
  38.   
  39. 4. 重新启动mysql  
  40.   
  41. [root@test ~]# /etc/init.d/mysqld restart  
  42. Stopping mysqld: [ OK ]  
  43. Starting mysqld: [ OK ]  
  44.   
  45. 5.再次登录后检查端口已修改为’3506’.  
  46.   
  47. [root@test etc]# mysql -u root -p  
  48. Enter password:  
  49. Welcome to the MySQL monitor. Commands end with ; or \g.  
  50. Your MySQL connection id is 2  
  51. Server version: 5.1.66 Source distribution  
  52.   
  53. Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved.  
  54.   
  55. Oracle is a registered trademark of Oracle Corporation and/or its  
  56. affiliates. Other names may be trademarks of their respective  
  57. owners.  
  58.   
  59. Type ‘help;’ or ‘\h’ for help. Type ‘\c’ to clear the current input statement.  
  60.   
  61. mysql> show global variables like ‘port’;  
  62. +—————+——-+  
  63. | Variable_name | Value |  
  64. +—————+——-+  
  65. | port | 3506 |  
  66. +—————+——-+  
  67. 1 row in set (0.00 sec)  
  68.   
  69. mysql>  
  70.   
  71. 总结:注意修改的端口不要被占用,而且要有规划,不要轻意的总是调整数据库端口。还有就是安全保障,记得与负责网络的人提前通知,以免端口无法正常使用。   
版权声明:本文为博主原创文章,未经博主允许欢迎转载。 https://blog.csdn.net/LANGZI7758521/article/details/51391932
版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 举报,一经查实,本站将立刻删除。

发布者:全栈程序员-用户IM,转载请注明出处:https://javaforall.cn/113373.html原文链接:https://javaforall.cn

【正版授权,激活自己账号】: Jetbrains全家桶Ide使用,1年售后保障,每天仅需1毛

【官方授权 正版激活】: 官方授权 正版激活 支持Jetbrains家族下所有IDE 使用个人JB账号...

(0)


相关推荐

发表回复

您的电子邮箱地址不会被公开。

关注全栈程序员社区公众号