debian 8 卸载MySQL5.5与安装MySQL5.7

1.卸载MySQL5.5

1.1卸载MySQL5.5

sudo apt-get --purge remove mysql*   # root用户去除sudo

1.2清理残余

sudo apt-get autoremove
sudo apt-get autoclean

2.安装MySQL5.7

2.1安装

wget http://dev.mysql.com/get/mysql-apt-config_0.8.9-1_all.deb

sudo dpkg -i mysql-apt-config_0.8.9-1_all.deb  # 弹出一个选择框,选择5.7,接下来点击ok就行了。

sudo apt-get update  #报错

sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 8C718D3B5072E1F5

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

2.2 配置安全脚本

sudo  mysql_secure_installation

安全脚本主要做如下事项,根据自己情况设置即可:
为root用户设置密码 y
删除匿名账号 n
取消root用户远程登录 n
删除test库和对test库的访问权限 n
刷新授权表使修改生效 y

root@kpw-0004:~# mysql_secure_installation

Securing the MySQL server deployment.

Enter password for user root: 

VALIDATE PASSWORD PLUGIN can be used to test passwords
and improve security. It checks the strength of password
and allows the users to set only those passwords which are
secure enough. Would you like to setup VALIDATE PASSWORD plugin?

Press y|Y for Yes, any other key for No: 
Using existing password for root.
Change the password for root ? ((Press y|Y for Yes, any other key for No) : 

 ... skipping.
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. This is intended only for
testing, and to make the installation go a bit smoother.
You should remove them before moving into a production
environment.

Remove anonymous users? (Press y|Y for Yes, any other key for No) : y
Success.


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) : n

 ... skipping.
By default, MySQL comes with a database named 'test' that
anyone can access. This is also intended only for testing,
and should be removed before moving into a production
environment.


Remove test database and access to it? (Press y|Y for Yes, any other key for No) : n

 ... skipping.
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
Success.

All done! 

2.3 登录并配置远程访问

mysql -u root -p # 输入密码
mysql> use mysql; 
mysql> update user set host = '%' where user = 'root'; 
mysql> select host, user from user; 
mysql> flush privileges;  # 退出mysql
sudo vim /etc/mysql/mysql.conf.d/mysqld.cnf;      # 注释掉 “bind 127.0.0.1”这一行

完毕!

你可能感兴趣的:(debian 8 卸载MySQL5.5与安装MySQL5.7)