ubuntu在线安装mysql


1.sudo apt-get update
2.sudo apt-get install mysql-server mysql-client

 3.mysqladmin --version
可以看到

 表示安装成功


或者输入
systemctl status mysql.service
看到

 4.mysql -u root -p然后输入安装界面设置的密码

 不输入密码登录不行。输入了123456以为系统会帮我默认用这个密码重置,结果还是不行

5.1切换到root用户,猜测密码默认是root,然后真的登录成功了,其实此时还不需要密码。

5.2尝试使用sudo权限操作,输入sudo mysql -u root

可以进入mysql执行窗口 ,然后执行8.3


6启动 mysql:
service mysql start
7.mysqladmin -p -u root version
看到mysqladmin  Ver 8.42 Distrib 5.7.22, for Linux on x86_64
Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Server version 5.7.22-0ubuntu0.16.04.1
Protocol version 10
Connection Localhost via UNIX socket
UNIX socket /var/run/mysqld/mysqld.sock
Uptime: 28 min 15 sec

此时还不能远程登录


 

8.先切换库,查看user表数据

select host,user,authentication_string from user;

 然后执行

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

flush privileges;

 还是不行哈,继续尝试办法

ALTER USER 'root'@'%' IDENTIFIED WITH mysql_native_password BY '123456';
flush privileges;

mysql服务器本地必须使用密码登录可以登录了,但是还是不能远程登录。

按下述方式修改mysqld.cnf,然后重启mysql

root@VM-8-10-ubuntu:/home/lighthouse# find / -name "mysqld.cnf"
/etc/mysql/mysql.conf.d/mysqld.cnf
root@VM-8-10-ubuntu:/home/lighthouse# vi /etc/mysql/mysql.conf.d/mysqld.cnf
root@VM-8-10-ubuntu:/home/lighthouse# service mysql restart
root@VM-8-10-ubuntu:/home/lighthouse# 

然后远程可以登录这个mysql了。

 

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值