zoukankan      html  css  js  c++  java
  • 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
  • 相关阅读:
    添加搜索引擎
    理解隐马尔可夫模型(转载)
    全排列合集
    COM使用简介
    KMP算法
    遗传算法(转载)
    退火算法(转载)
    非电信手机获取闪讯密码的一种实现方法
    几个时间控制函数(转载)
    图像处理的Alpha通道
  • 原文地址:https://www.cnblogs.com/lxwphp/p/15454442.html
Copyright © 2011-2022 走看看