Termux重置MariaDB(MySQL)密码

按顺序执行命令即可:

1
2
3
mysqld_safe --user=mysql --skip-grant-tables --skip-networking &

mysql -u root
1
2
3
4
5
6
7
flush privileges;

set password for 'root'@'localhost'=password('123456');

GRANT ALL PRIVILEGES ON *.* TO 'uesrname'@'%' IDENTIFIED BY 'password' WITH GRANT OPTION;#添加可以被外网访问的用户

flush privileges;

重启设备,如果打开mysql出错,提示ERROR 2002 (HY000): Can't connect to local server through socket '/data/data/com.termux/files/usr/var/run/mysqld.sock' (2),使用以下命令启动mysql:

1
nohup mysqld &