1. 程式人生 > >cent7.0 mysql 修改端口

cent7.0 mysql 修改端口

pin link moni all and log register 並且 rest

  1. 如何查看mysql 默認端口號和修改端口號 2015-03-19 17:42:18
  2. 1. 登錄mysql
  3. [root@test /]# mysql -u root -p
  4. Enter password:
  5. 2. 使用命令show global variables like ‘port‘;查看端口號
  6. mysql> show global variables like ‘port‘;
  7. +---------------+-------+
  8. | Variable_name | Value |
  9. +---------------+-------+
  10. | port | 3306 |
  11. +---------------+-------+
  12. 1 row in set (0.00 sec)
  13. 3. 修改端口,編輯/etc/my.cnf文件,早期版本有可能是my.conf文件名,增加端口參數,並且設定端口,註意該端口未被使用,保存退出。
  14. [root@test etc]# vi my.cnf
  15. [mysqld]
  16. port=3506
  17. datadir=/var/lib/mysql
  18. socket=/var/lib/mysql/mysql.sock
  19. user=mysql
  20. # Disabling symbolic-links is recommended to prevent assorted security risks
  21. symbolic-links=0
  22. [mysqld_safe]
  23. log-error=/var/log/mysqld.log
  24. pid-file=/var/run/mysqld/mysqld.pid
  25. "my.cnf" 11L, 261C written
  26. [root@test etc]#
  27. 4. 重新啟動mysql
  28. [root@test ~]# /etc/init.d/mysqld restart
  29. Stopping mysqld: [ OK ]
  30. Starting mysqld: [ OK ]
  31. 5.再次登錄後檢查端口已修改為’3506’.
  32. [root@test etc]# mysql -u root -p
  33. Enter password:
  34. Welcome to the MySQL monitor. Commands end with ; or \g.
  35. Your MySQL connection id is 2
  36. Server version: 5.1.66 Source distribution
  37. Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved.
  38. Oracle is a registered trademark of Oracle Corporation and/or its
  39. affiliates. Other names may be trademarks of their respective
  40. owners.
  41. Type ‘help;‘ or ‘\h‘ for help. Type ‘\c‘ to clear the current input statement.
  42. mysql> show global variables like ‘port‘;
  43. +---------------+-------+
  44. | Variable_name | Value |
  45. +---------------+-------+
  46. | port | 3506 |
  47. +---------------+-------+
  48. 1 row in set (0.00 sec)
  49. mysql>
  50. 總結:註意修改的端口不要被占用,而且要有規劃,不要輕意的總是調整數據庫端口。還有就是安全保障,記得與負責網絡的人提前通知,以免端口無法正常使用。

cent7.0 mysql 修改端口