发布网友 发布时间:2022-04-08 00:54
共2个回答
懂视网 时间:2022-04-08 05:16
/etc/apparmor.d/usr.sbin.mysqld修改完成后重启:/etc/init.d/apparmor restart
/usr/sbin/mysqld { #include <abstractions/base> #include <abstractions/nameservice> #include <abstractions/user-tmp> #include <abstractions/mysql> #include <abstractions/winbind> capability dac_override, capability sys_resource, capability setgid, capability setuid, network tcp, /etc/hosts.allow r, /etc/hosts.deny r, /etc/mysql/*.pem r, /etc/mysql/conf.d/ r, /etc/mysql/conf.d/* r, /etc/mysql/*.cnf r, /usr/lib/mysql/plugin/ r, /usr/lib/mysql/plugin/*.so* mr, /usr/sbin/mysqld mr, /usr/share/mysql/** r, /var/log/mysql.log rw, /var/log/mysql.err rw, /var/lib/mysql/ r, /var/lib/mysql/** rwk, /var/log/mysql/ r, /var/log/mysql/* rw, /var/run/mysqld/mysqld.pid rw, /var/run/mysqld/mysqld.sock w, /run/mysqld/mysqld.pid rw, /run/mysqld/mysqld.sock w, #####主要是添加这些读写权限信息,不然后期会报一些莫名的错误 /var/lib/mysql8/ r, /var/lib/mysql8/** rwk, /var/run/mysqld/mysqld8.pid rw, /var/run/mysqld/mysqld8.sock w, /run/mysqld/mysqld8.pid rw, /run/mysqld/mysqld8.sock w, /sys/devices/system/cpu/ r, # Site-specific additions and overrides. See local/README for details. #include <local/usr.sbin.mysqld> }
四、初始化数据库
mysql_install_db --user=mysql --datadir=/var/lib/mysql8 &
五、重新数据库(默认打开3306商品的数据库)
service mysql restart
六、打开新设置端口的数据库
mysqld_multi --defaults-file=/etc/mysql/my_multi.cnf start 8
七、完事,可以查看下了
netstat -ntlp
终于看到可喜的结果如下!
tcp 0 0 127.0.0.1:3306 0.0.0.0:* LISTEN 1402/mysqld tcp 0 0 127.0.0.1:3308 0.0.0.0:* LISTEN 2202/mysqld
Mysql多个端口设置
标签:
热心网友 时间:2022-04-08 02:24
mysql的默认端口是3306,但是并不是说一定要用这个,你可以自行修改成你想要的。但是登陆的是后就要指定端口登陆,并且如果你电脑有多个mysql的话,还要修改不同的sock。