1. 装包
sudo apt install mysql-server -y
2. 初始化
ubuntu22.04默认安装mysql8
新建mysql是没有密码的
mysql -uroot -p
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'Admin123!'; CREATE USER 'root'@'%' IDENTIFIED WITH mysql_native_password BY 'Admin123!';
exit;
echo default_authentication_plugin=mysql_native_password >> /etc/mysql/mysql.conf.d/mysqld.cnf grep port /etc/mysql/mysql.conf.d/mysqld.cnf echo 'port = 33066' >> /etc/mysql/mysql.conf.d/mysqld.cnf
sed -i 's/127.0.0.1/0.0.0.0/' /etc/mysql/mysql.conf.d/mysqld.cnf systemctl restart mysql ufw allow 33060 ufw allow 33066
然后就可以远程链接了mysql的root用户了:
mysql -h192.168.116.22 -uroot -p --port=33066
目前发现mysqlx暂时没什么用,先禁用掉吧
echo mysqlx=0 >> /etc/mysql/mysql.conf.d/mysqld.cnf sed -i '/^mysqlx-bind-address/s/^/#/' /etc/mysql/mysql.conf.d/mysqld.cnf systemctl restart mysql ufw delete allow 33060
标签:初始化,etc,ubuntu22.04,echo,cnf,myslq,mysqld,conf,mysql From: https://www.cnblogs.com/santia-god/p/17041369.html