Ubuntu18.04 安装MySQL

原文链接:https://blog.csdn.net/weixx3/article/details/80782479

环境信息:
OS:Ubuntu18.04
MySQL: 5.7.22

Ubuntu20安装mysql8 安装过程一样  开启远程权限不一样

亚马逊ec2主机使用ubuntu账户 以此方法安装 root账户会出错 很神奇

Ubuntu19.04 安装MySQL 8.0.16 见 --> 链接

1.安装MySQL
在Ubuntu中,默认情况下,只有最新版本的MySQL包含在APT软件包存储库中,要安装它,只需更新服务器上的包索引并安装默认包apt-get。

#命令1
sudo apt-get update
#命令2
sudo apt-get install mysql-server


2.配置MySQL
2.1 初始化配置
sudo mysql_secure_installation
1
配置项较多,如下所示:

#1
VALIDATE PASSWORD PLUGIN can be used to test passwords...
Press y|Y for Yes, any other key for No: N (我的选项)

#2
Please set the password for root here...
New password: (输入密码)
Re-enter new password: (重复输入)

#3
By default, a MySQL installation has an anonymous user,
allowing anyone to log into MySQL without having to have
a user account created for them...
Remove anonymous users? (Press y|Y for Yes, any other key for No) : N (我的选项)

#4
Normally, root should only be allowed to connect from
'localhost'. This ensures that someone cannot guess at
the root password from the network...
Disallow root login remotely? (Press y|Y for Yes, any other key for No) : Y (我的选项)

#5
By default, MySQL comes with a database named 'test' that
anyone can access...
Remove test database and access to it? (Press y|Y for Yes, any other key for No) : N (我的选项)

#6
Reloading the privilege tables will ensure that all changes
made so far will take effect immediately.
Reload privilege tables now? (Press y|Y for Yes, any other key for No) : Y (我的选项)


2.2 检查mysql服务状态
systemctl status mysql.service
1
显示如下结果说明mysql服务是正常的:

修改配置文件
  sudo vim /etc/mysql/mysql.conf.d/mysqld.cnf
  注:有的可能在 /etc/mysql/my.cnf

bind-address 0.0.0.0

重启mysql

service mysql restart

退出命令是 exit 或者 ctrl+c

————————————————
版权声明:本文为CSDN博主「Weison Wei」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/weixx3/article/details/80782479

=============================分割线====

mysql8     添加可以远程访问的账号

原文链接 https://blog.csdn.net/sunrj_niu/article/details/113350063
1.赋予权限

查看权限表

mysql> use mysql;
mysql> select host, user, authentication_string, plugin from user;

mysql> create user 'root'@'%' identified by '你自己的mysql密码';
mysql> grant all privileges on *.* to 'root'@'%';
mysql> flush privileges;
1
2
3
2.修改配置文件

cd  /etc/mysql/mysql.conf.d
1
 vi mysqld.cnf 
1
把bind 改成0.0.0.0

netstat -lntp

查看是否开始远程访问,变成0.0.0.0即成功

sudo ufw status

系统提示: “Status: inactive”状态:不活跃

 #开放端口:8080
/sbin/iptables -I INPUT -p tcp --dport 8080 -j ACCEPT

————————————————
版权声明:本文为CSDN博主「sunrj_go」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/sunrj_niu/article/details/113350063

=================================================

ubuntu彻底卸载mysql

在终端中查看MySQL的依赖项:dpkg --list|grep mysql

首先删除mysql:

sudo apt-get remove mysql-*

sudo apt-get purge mysql-*

然后清理残留的数据

dpkg -l |grep ^rc|awk '{print $2}' |sudo xargs dpkg -P

它会跳出一个对话框,你选择yes就好了

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值