MariaDB [(none)]>show global variables like 'port'; #查看端口号
MariaDB [(none)]>status; #查看mariadb的基本信息
[root@localhost ~]# mysql -u root -p123456 -P33077 -h192.168.9.85 #从库连接主库-p密码-P端口-h地址IP
修改MariaDB端口
mysql更改端口
修改/etc/my.cnf
添加port=3308
修改后如下
然后重启mysql
如果你开启了selinux,mysql会无法启动,你会在日志中看到以下错误
[ERROR] Can't start server: Bind on TCP/IP port: Permission denied
[ERROR] Do you already have another mysqld server running on port: 3308
那么,你需要关掉selinux,不想重启服务器,而关掉selinux,使用以下命令
/usr/sbin/setenforce 0
修改linux下mysql端口时候报错:
Can't start server: Bind on TCP/IP port: Permission denied
需要修改: vim /etc/selinux/config
SELINUX=disabled
然后重启服务器即可
[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
port=3308
user=mysql
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0
default-character-set=utf8
[mysqld_safe]
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid