修改端口,编辑/etc/my.cnf文件,早期版本有可能是my.conf文件名,增加端口参数,并且设定端口,注意该端口未被使用,保存退出。
[root@test etc]# vi my.cnf[mysqld]
port=3506
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
user=mysql
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0
[mysqld_safe]
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
"my.cnf" 11L, 261C written
[root@test etc]#
重新启动mysql
[root@test ~]# /etc/init.d/mysqld restartStopping mysqld: [ OK ]
Starting mysqld: [ OK ]
Linux下修改端口号只需要更改相应服务的配置文件即可,下面以修改linux 的SSH服务的默认端口号22为例(把22修改我2501):
1、修改/etc/ssh/sshd_config配置文件
[root@localhost ssh]# more sshd_config# $OpenBSD: sshd_config,v 1.69 2004/05/23 23:59:53 dtucker Exp $
# This is the sshd server system-wide configuration file. See
# sshd_config(5) for more information.
# This sshd was compiled with PATH=/usr/local/bin:/bin:/usr/bin
# The strategy used for options in the default sshd_config shipped with
# OpenSSH is to specify options with their default value where
# possible, but leave them commented. Uncommented options change a
# default value.
#Port 22 //先把22注释掉
port 2501 //添加一个新的端口
#Protocol 2,1
2、重启ssh服务让修改的端口号生效
[root@localhost ~]# service sshd restartStopping sshd:[ OK ]
Starting sshd:[ OK ]
关闭mongodb进程
ps-ef | grep mongo
kill 进程号
打开配置文件,修改端口
vi /etc/mongod.conf
port = 2888 #需要的端口
:wq #保存退出
启动mongodb
mongod -f /etc/mongod.conf
登录
mongo --port 2888
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)