1. 创建文件夹
cd /
mkdir mysql
cd mysql
2.下载mysql安装包
wget https://cdn.mysql.com//Downloads/MySQL-5.7/mysql-server_5.7.32-1ubuntu18.04_amd64.deb-bundle.tar
3.解压文件夹
tar -xvf mysql-server_5.7.32-1ubuntu18.04_amd64.deb-bundle.tar
解压出来的文件列表
1.png
4.按顺序安装(有依赖关系)
sudo dpkg -i mysql-common_5.7.32-1ubuntu18.04_amd64.deb
sudo dpkg -i libmysqlclient20_5.7.32-1ubuntu18.04_amd64.deb
sudo dpkg -i libmysqlclient-dev_5.7.32-1ubuntu18.04_amd64.deb
sudo dpkg -i libmysqld-dev_5.7.32-1ubuntu18.04_amd64.deb
sudo dpkg -i mysql-community-client_5.7.32-1ubuntu18.04_amd64.deb
sudo dpkg -i mysql-client_5.7.32-1ubuntu18.04_amd64.deb
sudo dpkg -i mysql-community-source_5.7.32-1ubuntu18.04_amd64.deb
4.1 继续安装mysql-community-server
sudo dpkg -i mysql-community-server_5.7.32-1ubuntu18.04_amd64.deb
执行这条命令时可能会报错 Package libmecab2 is not installed. 使用apt-get安装
sudo apt-get install libmecab2
如果之前有执行安装 mysql-community-server的命令时,当安装完libmecab2 就会弹出设置mysqlroot密码的界面
2.png
5.到这里已经安装完成。输入mysql -u root -p 即可登录
6.配置其他用户可以远程访问服务器
切到 /etc/mysql/my.cnf/mysql.conf.d路径下 打开 mysqld.cnf 文件(默认配置文件)
修改bind-address = 0.0.0.0
cd /etc/mysql/my.cnf/mysql.conf.d
vi mysqld.cnf
将bind-address = 127.0.0.1 修改为 0.0.0.0
如果没有这一条可以添加进去
修改完成后重启mysql,此时允许远端客户端连接,但是应该还是无法连接,还需要配置ip白名单
登录mysql
use mysql;
//your password 是你远程登录的那个账号的密码
grant all privileges on *.* to root@"要登录mysql的客户端的ip地址,为%号是表示允许所有ip" identified by 'your password' with grant option;
//刷新权限
flush privileges;
7.用户权限
3.png4.png
8.启动关闭命令
启动:
/etc/inint.d/mysql start
或
service mysql start
停止:
/etc/inint.d/mysql stop
或
service mysql stop
网友评论