It took a long time to change the password, record the installation process
Install ssh service:
sudo apt-get install openssh-server
Start ssh service:
service sshd start
Install mysql server:
sudo apt install -y mysql-server
Install the mysql client:
sudo apt install -y mysql-client
After the installation is completed, the password file is found according to the prompts:
/etc/mysql/debian.cnf
View the file and the display is as follows:
# 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
Modify the configuration file :
sudo vim /etc/mysql/my.cnf
Add the following configuration:
[mysql] default-character-set=utf8 [mysqld] port=3306 bind-address = 0.0.0.0 skip-grant-tables
Restart the database
sudo service mysql restart
Use the corresponding account and password to log in to mysql
mysql -udebian-sys-maint -pkYq3G8iSzqfXIXqb
Modify the root password and 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;
Delete the skip-grant-tables option after exiting
As follows:
[mysql] default-character-set=utf8 [mysqld] port=3306 bind-address = 0.0.0.0
Restart the mysql service
sudo service mysql restart;
Turn off the firewall
sudo service ufw disable; #关闭防火墙开机启动 sudo service ufw stop; #关闭防火墙服务
Use navicat on the host to test the link successfully:
The above is the detailed content of How to install and configure mysql 8.0.28 under ubuntu. For more information, please follow other related articles on the PHP Chinese website!