Ubuntu安装最新版MySQL数据库
时间:2016-12-16 19:02 来源:linux.it.net.cn 作者:IT
目前用的是Ubuntu最新的16.04,安装的MySQL版本是5.7.13,均为最新版本。
1
2
3
4
5
6
7
8
as@ansheng-me:~$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 16.04 LTS
Release: 16.04
Codename: xenial
as@ansheng-me:~$ uname -a
Linux ansheng-me 4.4.0-21-generic #37-Ubuntu SMP Mon Apr 18 18:33:37 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux
貌似现在不需要到官方下载MySQL的最新deb文件就可以直接安装最新版的MySQL了,OK,如果你需要下载最新的apt源,请执行下面的步骤,否则可以直接跳过。
1
2
3
4
wget http://dev.mysql.com/get/mysql-apt-config_0.7.3-1_all.deb
sudo dpkg -i mysql-apt-config_0.7.3-1_all.deb
sudo apt-get update
sudo apt-get install mysql-server-5.7
请选择MySQL5.7

ubuntu-install-mysql-01
我使用的阿里云的源,直接安装MySQL5.7即可。
1
as@ansheng-me:~$ sudo apt-get install mysql-server-5.7
输入MySQL的root密码

ubuntu-install-mysql-02
再次输入root密码

ubuntu-install-mysql-03
-
查看MySQL的版本
1
2
as@ansheng-me:~$ mysql -V
mysql Ver 14.14 Distrib 5.7.12, for Linux (x86_64) using EditLine wrapper
安装的既然是5.7.12,最新的是5.7.13.这都不影响使用。
-
更改字符串
1
2
3
4
5
6
7
as@ansheng-me:~$ sudo vim /etc/mysql/mysql.conf.d/mysqld.cnf
[mysqld]
......
character-set-server=utf8
[client]
default-character-set=utf8
-
启动并设置开机启动MySQL
1
2
3
4
as@ansheng-me:~$ sudo systemctl start mysql
as@ansheng-me:~$ sudo systemctl enable mysql
Synchronizing state of mysql.service with SysV init with /lib/systemd/systemd-sysv-install...
Executing /lib/systemd/systemd-sysv-install enable mysql
-
查看启动状态
1
2
3
as@ansheng-me:~$ sudo lsof -i :3306
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
mysqld 6185 mysql 16u IPv4 36472 0t0 TCP localhost:mysql (LISTEN)
-
登陆MySQL数据库
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
as@ansheng-me:~$ mysql -uroot -p123456
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 3
Server version: 5.7.12-0ubuntu1 (Ubuntu)
Copyright (c) 2000, 2016, 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> \s
--------------
mysql Ver 14.14 Distrib 5.7.12, for Linux (x86_64) using EditLine wrapper
Connection id: 3
Current database:
Current user: root@localhost
SSL: Not in use
Current pager: stdout
Using outfile: ''
Using delimiter: ;
Server version: 5.7.12-0ubuntu1 (Ubuntu)
Protocol version: 10
Connection: Localhost via UNIX socket
Server characterset: utf8
Db characterset: utf8
Client characterset: utf8
Conn. characterset: utf8
UNIX socket: /var/run/mysqld/mysqld.sock
Uptime: 3 sec
Threads: 1 Questions: 5 Slow queries: 0 Opens: 107 Flush tables: 1 Open tables: 26 Queries per second avg: 1.666
--------------
mysql> quit
Bye
(责任编辑:IT)
目前用的是Ubuntu最新的16.04,安装的MySQL版本是5.7.13,均为最新版本。
貌似现在不需要到官方下载MySQL的最新deb文件就可以直接安装最新版的MySQL了,OK,如果你需要下载最新的apt源,请执行下面的步骤,否则可以直接跳过。
请选择MySQL5.7
我使用的阿里云的源,直接安装MySQL5.7即可。
输入MySQL的root密码
再次输入root密码
安装的既然是5.7.12,最新的是5.7.13.这都不影响使用。
(责任编辑:IT) |