修改密碼改了挺長時間,記錄下安裝程序
安裝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測試連結成功:
#以上是ubuntu下mysql 8.0.28怎麼安裝配置的詳細內容。更多資訊請關注PHP中文網其他相關文章!