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