Ubuntu下mysql8.0安装与授权root远程登录

1.MySQL APT存储库的下载页面,下载社区版

MySQL :: Download MySQL Community Server

MySQL :: Download MySQL APT Repository

wget https://repo.mysql.com//mysql-apt-config_0.8.25-1_all.deb

2.安装mySQL APT存储库

sudo dpkg -i mysql-apt-config_0.8.25-1_all.deb

Once you are satisfied with the configuration then select last option 'Ok' to save the configuration, then run 'apt-get update' to load package list.
Advanced users can always change the configurations later, depending on their own needs.

  1. MySQL Server & Cluster (Currently selected: mysql-8.0)  3. MySQL Preview Packages (Currently selected: Disabled)
  2. MySQL Tools & Connectors (Currently selected: Enabled)  4. Ok

Which MySQL product do you wish to configure? 4
选择OK 即4.

3.使用以下命令从MySQL APT存储库更新包信息(此步骤是必需的): 

sudo apt-get update

4.使用APT安装MySQL

 sudo apt-get -y install mysql-server

这将安装MySQL服务器的包,以及客户端和数据库公共文件的包。

在安装过程中,您需要为MySQL安装的根用户提供密码。

MySQL 8 uses a new authentication based on improved SHA256-based password methods. It is recommended that all new MySQL Server installations use this
method going forward. This new authentication plugin requires new versions of connectors and clients, with support for this new authentication method
(caching_sha2_password). Currently MySQL 8 Connectors and community drivers built with libmysqlclient21 support this new method. Clients built with
older versions of libmysqlclient may not be able to connect to the new server.

To retain compatibility with older client software, the default authentication plugin can be set to the legacy value (mysql_native_password) This
should only be done if required third-party software has not been updated to work with the new authentication method. The change will be written to the
file /etc/mysql/mysql.conf.d/default-auth-override.cnf

After installation, the default can be changed by setting the default_authentication_plugin server setting.

  1. Use Strong Password Encryption (RECOMMENDED)  2. Use Legacy Authentication Method (Retain MySQL 5.x Compatibility)
Select default authentication plugin 2
 选择:2,即可

确保记住您设置的根密码。以后想设置密码的用户可以在对话框中将密码字段留空,然后按Ok;

在这种情况下,对于使用Unix套接字文件的连接,

对服务器的根访问将通过套接字对等凭据可插拔身份验证进行身份验证。

您可以稍后使用程序mysql_secure_installation设置根密码。

5.登录MySQL

 

mysql -u root -p

输入mysql的密码,进入mysql数据库后,使用如下sql语句:

切换到mysql

use mysql 

 

查询mysql中的user表的记录

select host , user , plugin ,authentication_string from mysql.user;

更改root用户的host为“%”,使root用户可以远程登录

update user set host='%' where user='root';

用exit退出mysql

exit

6.查看mysql运行情况

ps -elf|grep mysql

7.查看mysql运行时的端口

netstat -tlpn

8.重启mysql服务

sudo service mysql restart

  启动

  sudo service mysql start   

停止   

sudo service mysql stop
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值