Ubuntu 20.04 安装 MySQL 5.7 的教程 https://computingforgeeks.com/how-to-install-mysql-on-ubuntu-focal/
01 安装
sudo apt install mysql-server
02 进入mysql
sudo mysql
03 改密码,允许远程
use mysql;
update user set plugin='mysql_native_password' where user='root';
update user set authentication_string=PASSWORD('123456') where user='root';
update user set host='%' where user='root';
flush privileges;
quit;
04 允许远程
sudo vi /etc/mysql/mysql.conf.d/mysqld.cnf
注释掉 bind-address = 127.0.0.1
05 重启服务
sudo service mysql restart
创建数据库
CREATE DATABASE IF NOT EXISTS database_name DEFAULT CHARSET utf8 COLLATE utf8_general_ci;
CREATE DATABASE IF NOT EXISTS database_name DEFAULT CHARSET utf8mb4 COLLATE utf8mb4_general_ci;
导入数据
mysql -uroot -proot -D database_name -e "source /tmp/xxxxxx.sql"
网友评论