如何在一个空白的ecs上新建一个mysql服务
先购买一个ecs服务
买了一个这种配置的,入门级学习用的,400大洋
配置ubuntu
购买之后会配置实例,到时选择ubuntu就可以,然后设置密码;
开始安装
- 使用putty,很轻
- 获取mysql8的更新包
wget https://dev.mysql.com/get/mysql-apt-config_0.8.13-1_all.deb
30M左右 - 解压缩更新包
sudo dpkg -i mysql-apt-config_0.8.13-1_all.deb
- 拉取更新链接
sudo apt update
- 安装mysql服务
sudo apt install mysql-server
- 使用mysql安全服务
sudo mysql_secure_installation
- 查看mysql服务状态
systemctl status mysql.service
- 查看mysql版本
sudo mysqladmin -p -u root version
- 安装好之后访问mysql , 直接输入
sudo myql
即可, - 更改密码;
alter user 'root'@'localhost' identified with mysql_native_password by 'Qqww@123'
正常不用加'with mysql_native_password',之所以加,是因为一些第三方密码工具不及时; - 新建对外用户, '%'可以换成ip地址
create user 'yang'@'%' identified by 'Qqww@123';
- 分配权限
grant all privileges on *.* to 'yang'@'%' with grant option;
- 刷新权限
flush privileges
- 查看端口号
show global variables like 'port'
在外部这样netstat -an|grep 3306
- 创建新的schema
create schema mall default character set utf8 collate utf8_unicode_ci;
ecs安全组配置
复制一个规则,把它设为mysql的规则,
客户端配置
把mysql Workbence更新成8的就可以设置访问了.
卸载mysql
1、 sudo apt-get remove mysql-server
2、sudo apt-get autoclean
清除已卸载软件包 3、sudo apt-get remove mysql-common
--这个很重要 4、dpkg -l |grep ^rc|awk '{print $2}' |sudo xargs dpkg -P
-- 清除残留数据