当前位置:   article > 正文

Ubuntu-20.04安装MySQL 8_ubuntu20.04 mysql8.0

ubuntu20.04 mysql8.0

下载仓库地址

  1. 进入MySQL官网
    https://www.mysql.com/
    在这里插入图片描述
  2. 点击【Download】
    在这里插入图片描述
  3. 鼠标滑动到页面底部,选择【MySQL Community (GPL) Downloads »
    在这里插入图片描述4. 点击MySQL APT Repository
    在这里插入图片描述
  4. 点击Download
    在这里插入图片描述
  5. 点击No thanks, just start my download.,或者复制其地址:https://dev.mysql.com/get/mysql-apt-config_0.8.24-1_all.deb
    在这里插入图片描述
cd /usr/local/src/
wget https://dev.mysql.com/get/mysql-apt-config_0.8.24-1_all.deb

  • 1
  • 2
  • 3

安装

添加镜像库

dpkg -i mysql-apt-config_0.8.24-1_all.deb
apt update

  • 1
  • 2
  • 3

安装MySQL 8

apt install mysql-server

  • 1
  • 2

设置用户

mysql -uroot

CREATE USER 'root'@'%' IDENTIFIED BY '123456';
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%';
FLUSH PRIVILEGES;

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 修改root@localhost密码不生效
ALTER USER 'root'@'%' IDENTIFIED BY '123456';
  • 1

mysql -uroot还是能够登录?
问题可能是auth_socket认证引起的,执行以下命令查看是否为

mysql> select plugin,authentication_string from mysql.user where user = 'root';
+-----------------------+-------------------------------------------+
| plugin                | authentication_string                     |
+-----------------------+-------------------------------------------+
| auth_socket           |                                           |
+-----------------------+-------------------------------------------+
2 rows in set (0.00 sec)

mysql> 
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9

这个时候只需要修改认证方式为mysql_native_password即可

ysql> alter user 'root'@'localhost' identified with mysql_native_password by '123456';
Query OK, 0 rows affected (0.01 sec)

mysql> select plugin,authentication_string from mysql.user where user = 'root'
    -> ;
+-----------------------+-------------------------------------------+
| plugin                | authentication_string                     |
+-----------------------+-------------------------------------------+
| mysql_native_password | *6BB4837EB74329105EE4568DDA7DC67ED2CA2AD9 |
+-----------------------+-------------------------------------------+
1 row in set (0.00 sec)

mysql> exit
Bye
root@VM-0-5-ubuntu:/home/lighthouse# mysql -uroot
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)
root@VM-0-5-ubuntu:/home/lighthouse# mysql -uroot -p123456
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 36
Server version: 8.0.31 MySQL Community Server - GPL

Copyright (c) 2000, 2022, Oracle and/or its affiliates.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> 
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/菜鸟追梦旅行/article/detail/65144
推荐阅读
相关标签
  

闽ICP备14008679号