如何在ubuntu14.04 LTS上安装MySQL Server 5.7

时间:2019-08-20 17:58:17  来源:igfitidea点击:

安装MySQL Server 5.7准备工作

我们可以从mysql下载页面下载repository包。

使用wget命令将repo包下载到系统上。

sudo wget http://dev.mysql.com/get/mysql-apt-config_0.6.0-1_all.deb

使用dpkg命令,安装repo deb包。

sudo dpkg -i mysql-apt-config_0.6.0-1_all.deb

安装后,我们将在apt目录中找到新的更改,所以我们也来检查一下。

在安装mysql repo deb包之后,它将在 /etc/apt/sources.list.d/创建一个mysql.list文件。

运行命令cat /etc/apt/sources.list.d/mysql.list我们将在中看到一些mysql repo 地址。

cat /etc/apt/sources.list.d/mysql.list 
### THIS FILE IS AUTOMATICALLY CONFIGURED ###
# You may comment out entries below, but any other modifications may be lost.
# Use command 'dpkg-reconfigure mysql-apt-config' as root for modifications.
deb http://repo.mysql.com/apt/ubuntu/ trusty mysql-apt-config
deb http://repo.mysql.com/apt/ubuntu/ trusty mysql-5.7

deb-src http://repo.mysql.com/apt/ubuntu/ trusty mysql-5.7

安装MySQL Server 5.7

要在Ubuntu14.04LTS上安装MySQLServer5.7,运行下面的命令。

sudo apt-get update

sudo apt-get install mysql-server-5.7

几秒钟后,你将在你的终端上显示一些屏幕。这是MySQL Server的安装说明。
提供MySQL root密码。

测试检查mysql root用户

$ mysql -u root -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or g.
Your MySQL connection id is 2
Server version: 5.7.10 MySQL Community Server (GPL)

Copyright (c) 2000, 2015, 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服务启动/停止/重启/状态

(a) 在ubuntu中如何重启mysql服务

sudo service mysql restart

(b) 在ubuntu中启动mysql服务

sudo service mysql start

(c) 在ubuntu中停止mysql服务

sudo service mysql stop

(c) 在ubuntu中查看mysql服务的状态

sudo service mysql status