大家好,又见面了,我是你们的朋友全栈君。
关于mysql的端口号
先登录mysql:
fegy@fegy-X542UN:~$ mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 4
Server version: 5.7.26-0ubuntu0.18.04.1 (Ubuntu)
Copyright (c) 2000, 2019, 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.
输入命令:
show global variables like 'port';
mysql> show global variables like 'port';
+---------------+-------+
| Variable_name | Value |
+---------------+-------+
| port | 3306 |
+---------------+-------+
1 row in set (0.04 sec)
value的值即是自己的端口号;这里是3306,即默认端口号。
修改默认的端口号:
打开文件my.cnf,然后增加端口参数,设定端口,注意该端口应是未被使用的,注意一定要先保存再退出
fegy@fegy-X542UN:~$ vim 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
fegy@fegy-X542UN:~$
重启mysql:
fegy@fegy-X542UN:~$ service mysqld restart
查看mysql基本信息:
输入命令:
status;
mysql> status;
--------------
mysql Ver 14.14 Distrib 5.7.26, for Linux (x86_64) using EditLine wrapper
Connection id: 4
Current database:
Current user: root@localhost
SSL: Not in use
Current pager: stdout
Using outfile: ''
Using delimiter: ;
Server version: 5.7.26-0ubuntu0.18.04.1 (Ubuntu)
Protocol version: 10
Connection: Localhost via UNIX socket
Server characterset: latin1
Db characterset: latin1
Client characterset: utf8
Conn. characterset: utf8
UNIX socket: /var/run/mysqld/mysqld.sock
Uptime: 3 hours 10 min 3 sec
Threads: 1 Questions: 9 Slow queries: 0 Opens: 105 Flush tables: 1 Open tables: 98 Queries per second avg: 0.000
--------------
发布者:全栈程序员栈长,转载请注明出处:https://javaforall.cn/128806.html原文链接:https://javaforall.cn