当前位置: 移动技术网 > IT编程>数据库>Mysql > MySql修改默认端口的方法

MySql修改默认端口的方法

2018年09月24日  | 移动技术网IT编程  | 我要评论

有什么h动漫好看,中天电视,碧昂丝换装

1. 登录mysql

[root@test /]# mysql -u root -p

enter password:

2. 使用命令show global variables like 'port';查看端口号

mysql> show global variables like 'port';

+---------------+-------+

| variable_name | value |

+---------------+-------+

| port | 3306 |

+---------------+-------+

1 row in set (0.00 sec)

3. 修改端口,

编辑/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]#

4. 重新启动mysql

[root@test ~]#systemctl restart mysqld

5.再次登录后检查端口已修改为’3506’.

[root@test etc]# mysql -u root -p

enter password:

welcome to the mysql monitor. commands end with ; or \g.

your mysql connection id is 2

server version: 5.1.66 source distribution

copyright (c) 2000, 2012, oracle and/or its affiliates. all rights reserved.

oracle is a registered trademark of oracle corporation and/or its

affiliates. other names may be trademarks of their respective

owners.

type 'help;' or '\h' for help. type '\c' to clear the current input statement.

mysql> show global variables like 'port';

+---------------+-------+

| variable_name | value |

+---------------+-------+

| port | 3506 |

+---------------+-------+

1 row in set (0.00 sec)

mysql>

1. 登录mysql

[root@test /]# mysql -u root -p

enter password:

2. 使用命令show global variables like 'port';查看端口号

mysql> show global variables like 'port';

+---------------+-------+

| variable_name | value |

+---------------+-------+

| port | 3306 |

+---------------+-------+

1 row in set (0.00 sec)

3. 修改端口,

编辑/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]#

4. 重新启动mysql

[root@test ~]#systemctl restart mysqld

5.再次登录后检查端口已修改为’3506’.

[root@test etc]# mysql -u root -p

enter password:

welcome to the mysql monitor. commands end with ; or \g.

your mysql connection id is 2

server version: 5.1.66 source distribution

copyright (c) 2000, 2012, oracle and/or its affiliates. all rights reserved.

oracle is a registered trademark of oracle corporation and/or its

affiliates. other names may be trademarks of their respective

owners.

type 'help;' or '\h' for help. type '\c' to clear the current input statement.

mysql> show global variables like 'port';

+---------------+-------+

| variable_name | value |

+---------------+-------+

| port | 3506 |

+---------------+-------+

1 row in set (0.00 sec)

mysql>

如对本文有疑问,请在下面进行留言讨论,广大热心网友会与你互动!! 点击进行留言回复

相关文章:

验证码:
移动技术网