Ubuntu-18.04下安装mysql
安装mysql服务器
1、 sudo apt-get install mysql-server
2、 sudo apt-get install mysql-client
登录问题
安装成功后,我们会发现我们没有登录的权限。
hhz@hhz-virtual-machine:~$ mysql -u root -p
Enter password:
ERROR (): Access denied for user 'root'@'localhost'
然后发现当我们输入 sudo mysql -u root -p 这个命令的时候可以登录(提示输入密码时直接回车即可),显然这不是我们想要的。
那怎么解决这个问题呢?
解决方案:删除root用户,然后重新创建
1、我们先登录:
hhz@hhz-virtual-machine:~$ sudo mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is
Server version: 5.7.-0ubuntu0.18.04. (Ubuntu) Copyright (c) , , 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. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
2、然后查看用户:
mysql> select user,host from mysql.user;
+------------------+-----------+
| user | host |
+------------------+-----------+
| debian-sys-maint | localhost |
| mysql.session | localhost |
| mysql.sys | localhost |
| root | localhost |
+------------------+-----------+
rows in set (0.00 sec)
3、删除root帐号
mysql> drop user 'root'@'localhost';
Query OK, rows affected (0.00 sec)
4、重新创建一个root帐号
mysql> create user 'root'@'%' identified by '';
Query OK, rows affected (0.01 sec)
5、接下来我们用 quit; 命令来退出mysql,然后试试用新的帐号登录
hhz@hhz-virtual-machine:~$ mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is
Server version: 5.7.-0ubuntu0.18.04. (Ubuntu) Copyright (c) , , 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. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
ok,登录问题已经完美解决
远程访问问题
1、授权
mysql> grant all privileges on *.* to 'root'@'%' with grant option;
Query OK, rows affected (0.00 sec) mysql> flush privileges;
Query OK, rows affected (0.01 sec)
2、用 sudo vi /etc/mysql/mysql.conf.d/mysqld.cnf 打开这个文件,然后将 bind-address = 127.0.0.1 改成 bind-address = 0.0.0.0 允许任何IP地址访问,如果设置多个请用逗号隔开
3、重启服务: service mysql restart
4、接下来我们在windows下用Navicat来连接试试

Ubuntu-18.04下安装mysql的更多相关文章
- 在Ubuntu 18.04 下安装mysql,没有初始密码,重设root密码
在Ubuntu 18.04 下安装mysql 不知道是由于mysql更新为新版还是.Ubuntu18.04中的特性,安装过程中没有设置密码的环节,在网络上找了半天,总算解决了!特此记录下来,以便以后查 ...
- Ubuntu 18.04下安装Steam顶级在线游戏平台
Ubuntu 18.04下安装Steam顶级在线游戏平台 原创: 聆听世界的鱼 Linux公社 今天 Steam是由Valve公司开发的顶级在线游戏平台,是目前全球最大的综合性数字发行平台之一.它让你 ...
- 在 Ubuntu 18.04 下安装 fcitx 及搜狗拼音输入法
感觉自己傻逼透了,之前在 16.04 时折腾着要装 ibus 和 rime 输入法,现在 18.04 默认安装 ibus 了,又因为 rime 的智能联想太弱,打字不爽,又想装回搜狗一劳永逸... 环 ...
- Ubuntu 18.04.1 安装mysql 5.7.27
sudo apt-get update sudo apt-get install mysql-server 配置 sudo mysql_secure_installation 参考文档 Ubuntu1 ...
- ubuntu 18.04下安装Hadoop
在Ubuntu里装完Java环境后,接下来就开始学习安装Hadoop了,参照的是以下链接 https://blog.csdn.net/xuan314708889/article/details/805 ...
- ubuntu 18.04下安装配置HBase问题记录
参考资料: Ubuntu下HBase安装与使用(shell+Java API) 问题 无法正常启动hbase,在Log里报错java.lang.ClassNotFoundException: org. ...
- ubuntu 18.04下安装配置Hue问题记录
前段时间将Hadoop 在ubuntu环境下装好,接下来尝试安装Hue来管理Hadoop,参照的资料有: 1.高可用Hadoop平台-Hue In Hadoop 2.ubuntu16.04 安装单机H ...
- ubuntu 18.04下安装Java
参照以下链接,这个是我找到的最易上手的学习教程了 https://blog.csdn.net/sangewuxie/article/details/80958611 按其步骤,我下载的是Java 11 ...
- Ubuntu 18.04 下安装pip3及pygame模块
1.Ubuntu下pip3的安装.升级.卸载 安装pip3 sudo apt-get install python3-pip 升级pip3 sudo pip3 install --upgrade pi ...
- Ubuntu 16.04下安装MySQL及远程连接
最近因为要研究一个关于MySQL的漏洞,所以需要MySQL的环境,就用了近一个小时的时间搭建了一个,期间出了点问题,故记录于此. 1.首先是安装,在命令窗口中输入下面三条命令即可. sudo apt- ...
随机推荐
- Firefox、Chrome、IE9、IE8、IE7、IE6等浏览器HTTP_USER_AGENT汇总
Firefox.Chrome.IE9.IE8.IE7.IE6 浏览器HTTP_USER_AGENT汇总 结论: 浏览器 \ OS XP(IE6) XP(IE7) XP(IE8) Win7 x64(I ...
- java中为什么重写equals时必须重写hashCode方法?
在上一篇博文Java中equals和==的区别中介绍了Object类的equals方法,并且也介绍了我们可在重写equals方法,本章我们来说一下为什么重写equals方法的时候也要重写hashCod ...
- 八个常用的js正则表达式
开篇:开发中如果有input输入框,难免就要写正则表达式,因此在这里总结了一些常见常用的正则表达式的书写方法,希望会大家有所帮助: 附图: 一.手机号码 $(document).ready(funct ...
- [转]Calling an OData Service From a .NET Client (C#)
本文转自:https://docs.microsoft.com/en-us/aspnet/web-api/overview/odata-support-in-aspnet-web-api/odata- ...
- js弹出遮层
<script> var docEle = function () { return document.getElementById(arguments[0]) || false; } f ...
- Dapper扩展
using Dapper; using MySql.Data.MySqlClient; using System; using System.Collections.Generic; using Sy ...
- 对自写的Asp.Net分页控件的应用方式(异步无刷新分页)
前台代码 <!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" co ...
- 运行javac编译报错:仅当显式请求注释处理时才接受类名称“xxxxxx”
发生原因:运行javac编译时没有加上扩展名.解决方法:加上.java扩展名重新编译即可,"xxxxxx.java".
- R 语言—基本绘图
https://www.harding.edu/fmccown/r/ 这个网站上有壮观的 R 绘制的实际图形 下面只记录自己感兴趣的内容 单变量绘图下包含 1. 带状图 2. 茎叶图 3. 直方图 ...
- Mac下使用sublime Text打开隐藏目录
我们用 sublime Text 打开时,默认是看到非隐藏的目录和文件,如下图: 这时候在这个节目,按下 command +shift + 句号 快捷键,会自动切换 隐藏状态的, 这时候就可以切换成下 ...