修改密码改了挺长时间,记录下安装过程
安装ssh服务:
sudo apt-get install openssh-server
启动ssh服务:
service sshd start
安装mysql服务器端:
sudo apt install -y mysql-server
安装mysql客户端:
sudo apt install -y mysql-client
安装完成后根据提示找到了密码文件:
/etc/mysql/debian.cnf
查看该文件显示如下:
# Automatically generated for Debian scripts. DO NOT TOUCH! [client] host = localhost user = debian-sys-maint password = kYq3G8iSzqfXIXqb socket = /var/run/mysqld/mysqld.sock [mysql_upgrade] host = localhost user = debian-sys-maint password = kYq3G8iSzqfXIXqb socket = /var/run/mysqld/mysqld.sock
修改配置文件:
sudo vim /etc/mysql/my.cnf
添加如下配置:
[mysql] default-character-set=utf8 [mysqld] port=3306 bind-address = 0.0.0.0 skip-grant-tables
重启数据库
sudo service mysql restart
使用对应的帐号和密码登陆到mysql中
mysql -udebian-sys-maint -pkYq3G8iSzqfXIXqb
修改root密码和host
use mysql; grant all privileges on *.* to 'root'@'%' with grant option; update user set host='%', authentication_string='' where user='root' ; ALTER USER 'root'@'%' IDENTIFIED BY '1' PASSWORD EXPIRE NEVER; ALTER USER 'root'@'%' IDENTIFIED WITH mysql_native_password BY '1'; FLUSH PRIVILEGES; quit;
退出后删除skip-grant-tables选项
如下:
[mysql] default-character-set=utf8 [mysqld] port=3306 bind-address = 0.0.0.0
重启mysql服务
sudo service mysql restart;
关闭防火墙
sudo service ufw disable; #关闭防火墙开机启动 sudo service ufw stop; #关闭防火墙服务
在主机上使用navicat测试链接成功:
Das obige ist der detaillierte Inhalt vonSo installieren und konfigurieren Sie MySQL 8.0.28 unter Ubuntu. Für weitere Informationen folgen Sie bitte anderen verwandten Artikeln auf der PHP chinesischen Website!