记MySQL在Ubuntu(18.04.1 LTS)的安装

本文记录一次在Ubuntu(18.04.1 LTS)上安装MySql过程,安装后的mySQL版本为5.7.24。

安装环境
root@~virtual-machine:/etc# cat /etc/issue
Ubuntu 18.04.1 LTS
安装mySql

以下为按照命令,在提示需要输入 [Y/n] 时,输入Y.

root@~virtual-machine:~# sudo apt-get install mysql-server
root@~virtual-machine:~# sudo apt-get install mysql-client
root@~virtual-machine:~# sudo apt-get install libmysqlclient-dev
root@~virtual-machine:~#

安装完成后,进入mySql

root@~virtual-machine:~# mysql
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.7.24-0ubuntu0.18.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>

建立一个用户并授权。

mysql> GRANT ALL PRIVILEGES ON *.* TO 'user'@'%' IDENTIFIED BY 'password' WITH GRANT OPTION;
Query OK, 0 rows affected, 1 warning (0.03 sec)

mysql> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.00 sec)
修改mysqld.cnf配置并重启MySQL服务

在安装好后,需要修改MySQL配置,否则其他的数据电脑或虚拟机不能连接该MySQL服务。在/etc/mysql/mysql.conf.d/mysqld.cnf里面,注掉或者删掉bind-address = 127.0.0.1”,或者将bind-address = 127.0.0.1修改为“bind-address = 0.0.0.0”。

root@~virtual-machine:~# vi /etc/mysql/mysql.conf.d/mysqld.cnf
# Instead of skip-networking the default is now to listen only on
# localhost which is more compatible and is not less secure.
# bind-address           = 127.0.0.1

bind-address修改后,需要重启mySQL服务。

root@~virtual-machine:~# service mysql restart
通过Navicat 或者SQL Developer工具连接

在以上步骤完成后,可以通过Navicat或SQL Developer工具连接到已安装的MySQL。此处使用SQL Developer连接到安装的MySQL。

连接名(M):自己定义
用户名(U):该值为前面创建的用户user
口令(P):该值为前面创建的密码password
主机名(A):主机名为MySQL安装的地址
端口(R):端口为MySQL服务监听端口
在这里插入图片描述

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值