1.到MySql官网(https://dev.mysql.com/downloads/mysql/)下载tar包
2.上传到Ubuntu服务器下
我使用的是xftp软件上传的
a.本机下载安装xftp(本地是window10)
下载xftp,使用的是家庭免费版,下载过程需要填写姓名、邮件。安装直接跟着步骤下一步就行了。下载地址:家庭/学校免费 - NetSarang Website (xshell.com)
b.服务器(ubuntu18.04.3)开启ftp服务。
$> sudo apt-get install vsftpd #安装ftp
$> ls -l /etc/vsftpd.conf #查看vsftpd.conf是否可写,如果为只读文件,则增加写权限
$> sudo chmod 666 /etc/vsftpd.conf #vsftpd.conf增加写权限
$> vi /etc/vsftpd.conf #启用local_enable=YES、write_enable=YES
$> sudo service vsftpd restart #重启ftp服务
3.顺序执行以下命令
$> groupadd mysql #创建安工作组
如果执行groupadd mysql命令时报错误:
Command 'groupadd' is available in '/usr/sbin/groupadd'
The command could not be located because '/usr/sbin' is not included in the PATH environment variable.
This is most likely caused by the lack of administrative privileges associated with your user account.
groupadd: command not found
这个应该是由用户权限导致的报错,可以使用执行 sudo groupadd mysql,useradd命令也是一样的。
$> useradd -r -g mysql -s /bini/false mysql
#在mysql工作组(-g 指定工作组)下创建一个mysql的系统账号(-r 建立系统帐号),并设置为不可登录(-s 指定用户登入后所使用的shell,/bin/false不允许登录)
$> cd tools #进入tar文件所在目录,根据实际路径
$> tar -xvf mysql-server_8.0.29-1ubuntu18.04_amd64.deb-bundle.tar
解压后出现以下deb包:
libmysqlclient21_8.0.29-1ubuntu18.04_amd64.deb
libmysqlclient-dev_8.0.29-1ubuntu18.04_amd64.deb
mysql-client_8.0.29-1ubuntu18.04_amd64.deb
mysql-common_8.0.29-1ubuntu18.04_amd64.deb
mysql-community-client_8.0.29-1ubuntu18.04_amd64.deb
mysql-community-client-core_8.0.29-1ubuntu18.04_amd64.deb
mysql-community-client-plugins_8.0.29-1ubuntu18.04_amd64.deb
mysql-community-server_8.0.29-1ubuntu18.04_amd64.deb
mysql-community-server-core_8.0.29-1ubuntu18.04_amd64.deb
mysql-community-server-debug_8.0.29-1ubuntu18.04_amd64.deb
mysql-community-test_8.0.29-1ubuntu18.04_amd64.deb
mysql-community-test-debug_8.0.29-1ubuntu18.04_amd64.deb
mysql-server_8.0.29-1ubuntu18.04_amd64.deb
mysql-testsuite_8.0.29-1ubuntu18.04_amd64.deb
$> sudo dpkg-preconfigure mysql-community-server_*.deb #预配置MySQL服务器包(用于在中软件包安装之前询问问题,如果软件包不需要进行配置,则不会询问任何问题),执行后出现以下界面,要求输入root用户的密码
$> sudo dpkg -i mysql-{common,community-client-plugins,community-client-core,community-client,client,community-server-core,community-server,server}_*.deb
#按该顺序安装数据库公共文件包,客户端包,客户端元包,服务器包和服务器元包
出现了以下错误:
$> sudo apt-get -f install #使用apt-get进行修复依赖项
$> sudo dpkg -i mysql-{common,community-client-plugins,community-client-core,community-client,client,community-server-core,community-server,server}_*.deb
#再次执行安装命令,成功安装。
可以通过以下命令连接mysql
$> mysql -h host -u user -p # host使用主机名称或者ip,user使用MySQL的用户名称
执行命令并输入密码后,出现以下信息则说明成功连接,之后就可以写sql语句了: