Ubuntu18.10安装及卸载MySQL、Apache、PHP

这篇博客详细介绍了如何在Ubuntu18.10上安装和卸载MySQL、Apache及PHP。在安装MySQL过程中,涉及了密码设置、匿名用户管理和远程访问权限配置。卸载部分提到了Apache和PHP的完整卸载步骤,包括删除配置文件和清理依赖。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

MySQL

安装MySQL

sudo apt-get update
sudo apt-get install mysql-server

简单配置MySQL

 sudo mysql_secure_installation

配置项较多,如下所示:

VALIDATE PASSWORD PLUGIN can be used to test passwords…
Press y|Y for Yes, any other key for No: N
Please set the password for root here…
New password: (输入密码)
Re-enter new password: (重复输入)
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
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
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
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

配置远程访问

 sudo mysql -uroot -p

此时,进入数据库,只能使用sudo,按照一下修改,可以解决:
进入数据库,修改root密码:

#≤5.7
update mysql.user set authentication_string=PASSWORD('新密码'),plugin='mysql_native_password' where user='root';

#≥5.8
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '新密码';==这是一条命令,此处注意要改为因为英文标点符号==

刷新:

flush privileges;

此时通过mysql -u root -p 免sudo登录mysql了

卸载步骤

- sudo apt purge mysql-*
- sudo rm -rf /etc/mysql/
- sudo rm -rf /var/lib/mysql/
- sudo apt autoremove
- sudo apt autoclean

大功告成!

Apache

安装apache2

$ sudo apt-get install apache2
$ sudo /etc/init.d/apache2 restart

卸载apache

卸载命令:

$ sudo apt-get --purge remove apache2
$ sudo apt-get --purge remove apache2.2-common
$ sudo apt-get autoremove

(关键一步)找到没有删除掉的配置文件,一并删除

$ sudo find  /etc -name "*apache*" -exec  rm -rf {} \;
$ sudo rm -rf /var/www

完成!

卸载php7

  • 删除php的相关包及配置
sudo apt-get autoremove php7*
  • 删除关联
sudo find /etc -name "*php*" |xargs  rm -rf (root权限下运行)
  • 清除dept列表
sudo apt purge `dpkg -l | grep php| awk '{print $2}' |tr "\n" " "`
  • 检查是否卸载干净(无返回就是卸载完成)
dpkg -l | grep php7.0
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值