Home > Database > Mysql Tutorial > body text

How to install and configure mysql 8.0.28 under ubuntu

PHPz
Release: 2023-05-26 22:34:06
forward
1439 people have browsed it

It took a long time to change the password, record the installation process

Install ssh service:

sudo apt-get install openssh-server
Copy after login

Start ssh service:

service sshd start
Copy after login

Install mysql server:

sudo apt install -y mysql-server
Copy after login

Install the mysql client:

sudo apt install -y mysql-client
Copy after login

After the installation is completed, the password file is found according to the prompts:

/etc/mysql/debian.cnf
Copy after login

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
Copy after login

Modify the configuration file :

sudo vim /etc/mysql/my.cnf
Copy after login

Add the following configuration:

[mysql]
default-character-set=utf8
 
[mysqld]
port=3306
bind-address = 0.0.0.0
skip-grant-tables
Copy after login

Restart the database

sudo service mysql restart
Copy after login

Use the corresponding account and password to log in to mysql

mysql -udebian-sys-maint -pkYq3G8iSzqfXIXqb
Copy after login

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;
Copy after login

Delete the skip-grant-tables option after exiting

As follows:

[mysql]
default-character-set=utf8
 
[mysqld]
port=3306
bind-address = 0.0.0.0
Copy after login

Restart the mysql service

sudo service mysql restart;
Copy after login

Turn off the firewall

sudo service ufw disable; #关闭防火墙开机启动
sudo service ufw stop;    #关闭防火墙服务
Copy after login

Use navicat on the host to test the link successfully:

How to install and configure mysql 8.0.28 under ubuntu

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!

Related labels:
source:yisu.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template