zoukankan      html  css  js  c++  java
  • cent7.0 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. 总结:注意修改的端口不要被占用,而且要有规划,不要轻意的总是调整数据库端口。还有就是安全保障,记得与负责网络的人提前通知,以免端口无法正常使用。  
  • 相关阅读:
    Git core objects
    各平台预定义的宏
    跨平台获取可执行文件的目录
    Windows、Linux、Mac OSX编译jni动态库
    xmpp整理笔记:发送图片信息和声音信息
    xmpp整理笔记:聊天信息的发送与显示
    xmpp整理笔记:用户网络连接及好友的管理
    小技巧,如何在Label中显示图片
    xmpp整理笔记:xmppFramework框架的导入和介绍
    xmpp整理笔记:环境的快速配置(附安装包)
  • 原文地址:https://www.cnblogs.com/xuyatao/p/8004085.html
Copyright © 2011-2022 走看看