原文链接: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就好了