安装mysql服务,客户端及动态库。
apt update
apt install mysql-server
apt install mysql-client
apt install libmysqlclient-dev
设置root密码
mysql -u root -p
use mysql;
update user set plugin='mysql_native_password' where user='root';
update user set authentication_string=password('123456') where user='root';
flush privileges;
重启mysql服务
service mysql restart
设置用户能够远程访问
mysql -u root -p
grant all privileges on *.* to root@'%' identified by '123456' WITH GRANT OPTION;
flush privileges;
修改配置文件
vi /etc/mysql/mysql.conf.d/mysqld.cnf
将bind-address后的127.0.0.1 改为0.0.0.0
#bind-address = 127.0.0.1
bind-address = 0.0.0.0
重启mysql服务
参考: ubuntu18.04上安装配置MySQL的详细介绍_MarsenSeven的博客-CSDN博客_ubuntu18.04安装mysql