在Ubuntu 18.04 LTS 命令行安装MySql5.7

安装环境

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服务监听端口

在Ubuntu 18.04 LTS 命令行安装MySql5.7_第1张图片

 

 


--------------------- 
作者:java_foryou    来源:CSDN 
原文:https://blog.csdn.net/java_foryou/article/details/83624663 

 

 

你可能感兴趣的:(mysql,ubuntu)