Ubuntu 18.04 安装mysql5.7

作者:lynnyq 时间:2024-01-26 07:53:09 

Ubuntu18.04安装mysql5.7,供大家参考,具体内容如下

1.1安装

首先执行下面三条命令:


# 安装mysql服务
sudo apt-get install mysql-server
# 安装客户端
sudo apt install mysql-client
# 安装依赖
sudo apt install libmysqlclient-dev
# 检查状态
sudo netstat -tap | grep mysql

1.2设置root密码

mysql5.7安装完成后普通用户不能进mysql,原因:root的plugin被修改成了auth_socket,用密码登陆的plugin应该是mysql_native_password,直接用root权限登录就不用密码,修改root密码和登录验证方式:


$ sudo su
# mysql
mysql>
mysql> select user, plugin from mysql.user;
+------------------+-----------------------+
| user | plugin |
+------------------+-----------------------+
| root | auth_socket |
| mysql.session | mysql_native_password |
| mysql.sys | mysql_native_password |
| debian-sys-maint | mysql_native_password |
+------------------+-----------------------+
4 rows in set (0.00 sec)
mysql> update mysql.user set authentication_string=PASSWORD('123456'), plugin='mysql_native_password' where user='root';
mysql> flush privileges;
mysql> exit
Bye
# exit
$ sudo /etc/init.d/mysql restart
$ mysql -uroot -p

Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.7.22-0ubuntu18.04.1 (Ubuntu)

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.

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

mysql>

1.3配置mysql远程登录


# 修改配置文件,注释掉bind-address = 127.0.0.1
$ sudo vi /etc/mysql/mysql.conf.d/mysqld.cnf

# 保存退出,然后进入mysql服务,执行授权命令:
$ mysql -uroot -p

mysql> grant all on *.* to root@'%' identified by '123456' with grant option;
Query OK, 0 rows affected, 1 warning (0.00 sec)

mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)

mysql> exit
Bye
$ sudo /etc/init.d/mysql restart

精彩专题分享:

mysql不同版本安装教程

mysql5.7各版本安装教程

mysql5.6各版本安装教程

mysql8.0各版本安装教程

来源:https://blog.csdn.net/lynnyq/article/details/80296137

标签:ubuntu18.04,mysql5.7
0
投稿

猜你喜欢

  • 使用正则表达式匹配tsql注释语句

    2024-01-18 16:42:50
  • matlab中二维插值函数interp2的使用详解

    2023-08-11 00:28:45
  • python三元运算符实现方法

    2022-08-19 23:11:34
  • 基于python分享一款地理数据可视化神器keplergl

    2023-09-27 20:54:05
  • python两种获取剪贴板内容的方法

    2021-03-05 11:18:56
  • mssqlserver恢复ldf文件数据的方法

    2024-01-22 11:06:54
  • Python3以GitHub为例来实现模拟登录和爬取的实例讲解

    2022-01-17 14:52:02
  • python数据可视化使用pyfinance分析证券收益示例详解

    2022-05-24 06:59:13
  • 对Python w和w+权限的区别详解

    2022-11-30 09:40:15
  • Bootstrap每天必学之工具提示(Tooltip)插件

    2023-07-02 05:25:22
  • 用ASP显示ACCESS数据库的GIF图象

    2008-11-16 18:09:00
  • vant中的toast轻提示实现代码

    2024-04-26 17:38:53
  • 玩转markdown 分享几个需要用到的工具

    2023-01-29 22:53:20
  • python中添加模块导入路径的方法

    2021-12-17 14:35:30
  • XMLHTTP错误The server name or address could not be resolved 的解决过程

    2009-12-26 18:33:00
  • python处理xml文件操作详解

    2021-11-10 10:31:24
  • Python八个自动化办公的技巧

    2023-09-14 07:58:19
  • Sql注入工具_动力节点Java学院整理

    2024-01-20 00:02:10
  • python+ffmpeg批量去视频开头的方法

    2021-07-07 16:10:01
  • 微信小程序webview组件交互,内联h5页面并网页实现微信支付实现解析

    2023-07-02 05:30:09
  • asp之家 网络编程 m.aspxhome.com