安装
sudo apt-get install mysql-server -y
卸载
sudo apt purge mysql-*
sudo rm -rf /etc/mysql/ /var/lib/mysql
sudo apt autoremove
sudo apt autoclean`
修改/etc/mysql/mysql.conf.d/mysqld.cnf配置文件重启:
注释掉地址绑定:
#bind-address = 127.0.0.1
#mysqlx-bind-address = 127.0.0.1
重启:
sudo systemctl restart mysql
查看mysql监听端口:
sudo netstat -anp|grep mysql
无密码进入mysql后设置远程访问
sudo mysql -u root
UPDATE user SET host = '%' WHERE user = 'root';
修改密码
ALTER USER 'root' IDENTIFIED WITH mysql_native_password BY '12345678';
忘记密码可以使用/etc/mysql/debian.cnf里的密码登录然后把authentication_string设置为空:
update user set authentication_string='' where user='root'
退出后不用密码登录,然后使用上面的修改密码语句修改密码。
标签:8.0,Ubuntu22.04,sudo,apt,密码,user,mysql,MySQL,root From: https://www.cnblogs.com/yanshaoshuai/p/17426360.html