1、Ubuntu系统下mysql安装
一、通过ssh登录阿里云服务器,查看是否安装了mysql。
root@iZm5ehpd3tjpeb8jq2pghhZ:~# sudo netstat -tap | grep mysql
root@iZm5ehpd3tjpeb8jq2pghhZ:~#
出现以上情况,则表明没有安装数据库
二、安装mysql数据库。
1、输入下面指令,进行安装。
root@--:~# sudo apt-get install mysql-server mysql-client
2、安装过程出现下面界面,进行设置密码即可。
3、安装完成,测试。
root@iZm5ehpd3tjpeb8jq2pghhZ:~# mysql --version
mysql Ver 14.14 Distrib 5.7.17, for Linux (x86_64) using EditLine wrapper
三、数据操作指令。
1、mysql打开状态。
root@iZm5ehpd3tjpeb8jq2pghhZ:~# service mysql status
● mysql.service - MySQL Community Server
Loaded: loaded (/lib/systemd/system/mysql.service; enabled; vendor preset: enabled)
Active: active (running) since Wed 2018-09-12 14:46:28 CST; 1 day 20h ago
Process: 2211 ExecStartPost=/usr/share/mysql/mysql-systemd-start post (code=exited, status=0/SUCCESS)
Process: 2201 ExecStartPre=/usr/share/mysql/mysql-systemd-start pre (code=exited, status=0/SUCCESS)
Main PID: 2210 (mysqld)
CGroup: /system.slice/mysql.service
└─2210 /usr/sbin/mysqld
Sep 12 14:46:27 iZm5ehpd3tjpeb8jq2pghhZ systemd[1]: Starting MySQL Community Server...
Sep 12 14:46:28 iZm5ehpd3tjpeb8jq2pghhZ systemd[1]: Started MySQL Community Server.
2、打开/关闭数据库。
root@iZm5ehpd3tjpeb8jq2pghhZ:~# service mysql stop
root@iZm5ehpd3tjpeb8jq2pghhZ:~# service mysql status
root@iZm5ehpd3tjpeb8jq2pghhZ:~# service mysql stop
root@iZm5ehpd3tjpeb8jq2pghhZ:~# service mysql status
● mysql.service - MySQL Community Server
Loaded: loaded (/lib/systemd/system/mysql.service; enabled; vendor preset: enabled)
Active: inactive (dead) since Fri 2018-09-14 10:50:34 CST; 3s ago
Process: 2211 ExecStartPost=/usr/share/mysql/mysql-systemd-start post (code=exited, status=0/SUCCESS)
Process: 2210 ExecStart=/usr/sbin/mysqld (code=exited, status=0/SUCCESS)
Process: 2201 ExecStartPre=/usr/share/mysql/mysql-systemd-start pre (code=exited, status=0/SUCCESS)
Main PID: 2210 (code=exited, status=0/SUCCESS)
Sep 12 14:46:27 iZm5ehpd3tjpeb8jq2pghhZ systemd[1]: Starting MySQL Community Server...
Sep 12 14:46:28 iZm5ehpd3tjpeb8jq2pghhZ systemd[1]: Started MySQL Community Server.
Sep 14 10:50:31 iZm5ehpd3tjpeb8jq2pghhZ systemd[1]: Stopping MySQL Community Server...
Sep 14 10:50:34 iZm5ehpd3tjpeb8jq2pghhZ systemd[1]: Stopped MySQL Community Server.
root@iZm5ehpd3tjpeb8jq2pghhZ:~# service mysql start
root@iZm5ehpd3tjpeb8jq2pghhZ:~# service mysql status
root@iZm5ehpd3tjpeb8jq2pghhZ:~# service mysql start
root@iZm5ehpd3tjpeb8jq2pghhZ:~# service mysql status
● mysql.service - MySQL Community Server
Loaded: loaded (/lib/systemd/system/mysql.service; enabled; vendor preset: enabled)
Active: active (running) since Fri 2018-09-14 10:51:22 CST; 1s ago
Process: 4803 ExecStartPost=/usr/share/mysql/mysql-systemd-start post (code=exited, status=0/SUCCESS)
Process: 4793 ExecStartPre=/usr/share/mysql/mysql-systemd-start pre (code=exited, status=0/SUCCESS)
Main PID: 4802 (mysqld)
CGroup: /system.slice/mysql.service
└─4802 /usr/sbin/mysqld
Sep 14 10:51:21 iZm5ehpd3tjpeb8jq2pghhZ systemd[1]: Starting MySQL Community Server...
Sep 14 10:51:22 iZm5ehpd3tjpeb8jq2pghhZ systemd[1]: Started MySQL Community Server.
二、使用navicat连接阿里云服务器的mysql数据库出现10038错误的解决办法
1、在阿里云服务器添加安全组规则,开放3306接口。
出口方也要对应的配置
修改/etc/mysql/mysql.conf.d/mysqld.cnf文件 将bind-address = 127.0.0.1
设置成bind-address = 0.0.0.0(设备地址)
连接成功: