Ubantu 下安装MYSQL5.7

记录下个人在ubantu20.04安装mysql5.7的过程

开始时是打算用安装包安装的,但是下载下安装包解压后安装报错.deb文件损坏可能是下载时候出的问题就改用了源安装

1,添加源

$ wget https://dev.mysql.com/get/mysql-apt-config_0.8.12-1_all.deb

2,安装存储库

$ sudo dpkg -i mysql-apt-config_0.8.12-1_all.deb 

2.1选择 Ubuntu bionic,然后单击确定

 2.2提示显示默认选择的MySQL 8.0。选择第一个选项,然后单击确定

 2.3选择 MySQL 5.7 服务器,然后单击确定

 2.4提示默认选择MySQL5.7。选择最后一个 Ok,然后单击 OK

3,更新软件包

$sudo apt update  

如报错:

命中:1 http://security.ubuntu.com/ubuntu focal-security InRelease
获取:2 http://repo.mysql.com/apt/ubuntu bionic InRelease [20.0 kB]
命中:3 http://mirrors.tuna.tsinghua.edu.cn/ubuntu focal InRelease
命中:4 http://mirrors.tuna.tsinghua.edu.cn/ubuntu focal-updates InRelease
命中:5 http://mirrors.tuna.tsinghua.edu.cn/ubuntu focal-backports InRelease
错误:2 http://repo.mysql.com/apt/ubuntu bionic InRelease 
  由于没有公钥,无法验证下列签名: NO_PUBKEY B7B3B788A8D3785C
正在读取软件包列表... 完成
W: GPG 错误:http://repo.mysql.com/apt/ubuntu bionic InRelease: 由于没有公钥,无法验证下列签名: NO_PUBKEY B7B3B788A8D3785C
E: 仓库 “http://repo.mysql.com/apt/ubuntu bionic InRelease” 没有数字签名。
N: 无法安全地用该源进行更新,所以默认禁用该源。
N: 参见 apt-secure(8) 手册以了解仓库创建和用户配置方面的细节。

注意这两个值要一样

执行 

apt-key adv --keyserver keyserver.ubuntu.com --recv B7B3B788A8D3785C

$ sudo apt update  再次更新

4,查看mysql5.7 包

$ apt-cache policy mysql-server

5, 安装 MySQL 5.7

$ sudo apt install -f mysql-client=5.7* mysql-community-server=5.7* mysql-server=5.7*
6,$ sudo mysql_secure_installation
当系统提示输入密码时,请提供上面设置的 root 密码。设置用户的密码长度,用户登录账号权限

Enter current password for root (enter for none): <Enter password>
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: Y 

There are three levels of password validation policy: 

LOW    Length >= 8 
MEDIUM Length >= 8, numeric, mixed case, and special characters 
STRONG Length >= 8, numeric, mixed case, special characters and dictionary                 

Please enter 0 = LOW, 1 = MEDIUM and 2 = STRONG: 1 
Using existing password for root. 
Estimated strength of the password: 25  
Change the password for root ? ((Press y|Y for Yes, any other key for No) : d
Remove anonymous users? [Y/n] Y 
Disallow root login remotely? [Y/n] Y 
Remove test database and access to it? [Y/n] Y 
Reload privilege tables now? [Y/n] Y 
Thanks for using MariaDB!

7,修改配置文件

/etc/mysql/mysql.conf.d$ sudo vi mysqld.cnf
查找行“bind_address”并更改如下:

# By default we only accept connections from localhost 
#bind-address   = 127.0.0.1 
bind-address   = 0.0.0.0

八,$ systemctl restart mysql 重启服务
九,$
sudo systemctl status mysql 查看服务状态
十,修改用户权限

$ mysql -u root -p
 
mysql> use mysql
mysql> select host,user from user;
mysql> update user set host='%' where user='root';
mysql> select host,user from user;
mysql> flush privileges;
十一,远程测试连接

  • 37
    点赞
  • 25
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
要在Ubuntu安装MySQL5.7,可以按照以下步骤进行操作: 1. 首先,执行以下命令来安装MySQL服务: ``` sudo apt update sudo apt install mysql-server-5.7 ``` 这将会安装MySQL 5.7的服务器组件。 2. 在安装过程中,系统会提示你设置root用户的密码。请根据提示输入并确认密码。 3. 安装完成后,可以通过以下命令验证MySQL版本: ``` dpkg -l | grep mysql ``` 在输出结果中,你应该能够看到mysql的版本为5.7.x。 请注意,安装完成后,可能会遇到普通用户无法登录MySQL的问题。这是因为在安装过程中,root用户的plugin被修改为了auth_socket,而不是密码登录的plugin。为了解决这个问题,你可以按照以下步骤进行设置: 1. 以root用户身份登录到MySQL服务: ``` sudo mysql -u root ``` 2. 在MySQL命令行中,执行以下命令更改root用户的认证方式: ``` ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '你的密码'; ``` 请将"你的密码"替换为你的MySQL root密码。 3. 执行以下命令刷新权限: ``` FLUSH PRIVILEGES; ``` 现在,你应该可以使用root用户的密码进行MySQL登录了。 希望这些信息对你有帮助。如果还有其他问题,请随时提问。<span class="em">1</span><span class="em">2</span><span class="em">3</span> #### 引用[.reference_title] - *1* *3* [Ubuntu20.04安装MySQL5.7-实测3种方法(保姆级教程)](https://blog.csdn.net/liuhuango123/article/details/128264867)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"] - *2* [Ubuntu 18.04 安装mysql5.7](https://download.csdn.net/download/weixin_38640794/14090649)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"] [ .reference_list ]

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值