MySql修改預設埠的方法

2021-12-30 07:17:03 字數 3135 閱讀 1228

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>

修改xampp的mysql預設密碼和埠

修改mysql預設密碼 mysql 的 root 使用者預設狀態是沒有密碼的,所以在 php 中您可以使用 mysql connect localhost root 來連線 mysql 伺服器 如果您想為 mysql 中的 root 使用者設定密碼,請在控制台中使用 mysqladmin 命令。例如...

修改 Apache 的預設埠

修改 apache 的預設埠 修改 apache 埠的方法是最妥協的方法了,後果是當你開啟 apache 伺服器的時候,訪問的本機位址將會附帶埠號,比如 http localhost 8888 修改方式是直接修改 httpd.conf 檔案,檔案的位置在 apache 安裝目錄下的 conf 資料夾...

修改Apache預設埠

一般預設是listen 80,表示監聽所有80埠的所有非特定請求 如果增加一行listen 800,表示增加監聽800埠的所有非特定請求 如果增加一行listen ip或網域名稱 801,表示監聽801埠,但只有該網域名稱或ip的訪問請求才作出回應。另外可以增加虛擬主機的選項,虛擬主機可以基於不同i...