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”这一行

完毕!

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • 一、Python简介和环境搭建以及pip的安装 4课时实验课主要内容 【Python简介】: Python 是一个...
    _小老虎_阅读 5,926评论 0 10
  • MySQL5.6从零开始学 第一章 初始mysql 1.1数据库基础 数据库是由一批数据构成的有序的集合,这些数据...
    星期四晚八点阅读 1,197评论 0 4
  • 安装并配置MySQL数据库 3.2.1安装MySQL数据库 1.MySQL数据库的安装环境准备 如果读者没有物理服...
    SkTj阅读 4,130评论 0 6
  • mysqladmin -u root -p oldpass password newpass mysqladmin...
    不排版阅读 2,275评论 0 3
  • 关于成长 这是一个悲伤的年代,我们生活的年代。我们小的时候,爸妈给我们说了很多人生应该坚持的信念,可是渐渐,他们不...
    宁缺灬阅读 177评论 0 1