数据库
首页 > 数据库> > Linuxu服务器ubantu安装MySQL 5.5版本升级5.7

Linuxu服务器ubantu安装MySQL 5.5版本升级5.7

作者:互联网

本文参考:https://www.jianshu.com/p/2316ec970946

     https://blog.csdn.net/qq_37392932/article/details/81011150

ubantu下安装数据库,本想安装5.7的但是在ubantu14.04 我总是安装显示5.5的版本 最终升级为5.5.62

1.下载mysql-apt 配置包,并安装,在安装过程中会让选择mysql版本号,选择5.7版本后,点击OK

2.更新apt-get

更新时可能出现错误如:

解决办法:

先查看执行命令:apt-key list
---------------------------------------------
pub 4096R/89DF5277 2010-07-11
uid Guillaume Plessis <gui@dotdeb.org>
sub 4096R/3D624A3B 2010-07-11
sub 4096R/A2098A6E 2010-07-11
pub 1024D/5072E1F5 2003-02-03 [expired: 2017-02-16]
uid MySQL Release Engineering <mysql-build@oss.oracle.com>
---------------------------------------------
删除mysql 的repository GPG key,删除命令如下:
sudo apt-key del 5072E1F5 
---------------------------------------------
删除完了之后,检查还有没有那个mysql的key
没有了,执行命令:apt-key adv --keyserver pgp.mit.edu --recv-keys A4A9406876FCBD3C456770C88C718D3B5072E1F5

如下输出
--------------------------------------------------
Executing: gpg --ignore-time-conflict --no-options --no-default-keyring --homedir /tmp/tmp.z5SEIWWrbt --no-auto-check-trustdb --trust-model always --keyring /etc/apt/trusted.gpg --primary-keyring /etc/apt/trusted.gpg --keyring /etc/apt/trusted.gpg.d/debian-archive-jessie-automatic.gpg --keyring /etc/apt/trusted.gpg.d/debian-archive-jessie-security-automatic.gpg --keyring /etc/apt/trusted.gpg.d/debian-archive-jessie-stable.gpg --keyring /etc/apt/trusted.gpg.d/debian-archive-squeeze-automatic.gpg --keyring /etc/apt/trusted.gpg.d/debian-archive-squeeze-stable.gpg --keyring /etc/apt/trusted.gpg.d/debian-archive-wheezy-automatic.gpg --keyring /etc/apt/trusted.gpg.d/debian-archive-wheezy-stable.gpg --keyring /etc/apt/trusted.gpg.d/php.gpg --keyserver pgp.mit.edu --recv-keys A4A9406876FCBD3C456770C88C718D3B5072E1F5
gpg: requesting key 5072E1F5 from hkp server pgp.mit.edu
gpg: key 5072E1F5: "MySQL Release Engineering <mysql-build@oss.oracle.com>" 62 new signatures
gpg: Total number processed: 1
gpg: new signatures: 62
--------------------------------------------------

完成后,再执行apt-get update

3.在安装数据库过程中会自动卸载老版本数据

这个过程会提示你输入密码,该密码就是登录密码

4.安装mysql 后,使用mysql_upgrade升级数据库文件版本

5.重启mysql,并检查数据是否正常

6.数据库命令

  #进入MySQL: mysql -u root -p

    #启动: sudo service mysql start

    #重启:sudo  service mysql restart 

  #关闭: sudo service mysql stop

7.数据库配置字符类型为utf8

修改MySQL配置文件(/et/mysql/my.cnf)如下:

[client]

default_character_set=utf8
[mysql]
default_character_set=utf8
[mysqld]
character_set_server=utf8

8.更新数据库密码并可以远程连接数据库

>use mysql;

> update user set authentication_string=PASSWORD("这里输入你要改的密码") where User='root'; #更改密码  我使用了这行
> update user set plugin="mysql_native_password"; #如果没这一行可能也会报一个错误,因此需要运行这一行

> flush privileges; #更新所有操作权限

>ALTER USER 'root'@'localhost' IDENTIFIED BY 'MyNewPass4!'  (修改密码)
>GRANT ALL PRIVILEGES ON *.* TO 'myuser'@'%'IDENTIFIED BY 'mypassword' WITH GRANT OPTION;
>FLUSH PRIVILEGES(开启远程访问)

然后重启数据库:

附带:ubant卸载mysql

1 2 3 4 sudo apt-get autoremove --purge mysql-server-5.0 sudo apt-get remove mysql-server sudo apt-get autoremove mysql-server sudo apt-get remove mysql-common

清除残留数据

1 dpkg -l |grep ^rc|awk '{print $2}' |sudo xargs dpkg -P

 

本文只为自己后续使用

标签:ubantu,5.5,gpg,keyring,apt,etc,版本升级,mysql,sudo
来源: https://www.cnblogs.com/cc19/p/11523707.html