mysql ubuntu安装_ubuntu系统下安装最新版的MySQL

下载mysql源

打开mysql官网

下载mysql源

apt-get install -y wget #如果没有wget命令就安装一下

wget https://dev.mysql.com/get/mysql-apt-config_0.8.15-1_all.deb

dpkg -i mysql-apt-config_0.8.15-1_all.deb

选择1,2,4

root@7c609eaf61d3:/usr/local/src# dpkg -i mysql-apt-config_0.8.15-1_all.deb

(Reading database ... 8304 files and directories currently installed.)

Preparing to unpack mysql-apt-config_0.8.15-1_all.deb ...

Unpacking mysql-apt-config (0.8.15-1) over (0.8.15-1) ...

Setting up mysql-apt-config (0.8.15-1) ...

debconf: unable to initialize frontend: Dialog

debconf: (No usable dialog-like program is installed, so the dialog based frontend cannot be used. at /usr/share/perl5/Debconf/FrontEnd/Dialog.pm line 76.)

debconf: falling back to frontend: Readline

debconf: unable to initialize frontend: Readline

debconf: (Can't locate Term/ReadLine.pm in @INC (you may need to install the Term::ReadLine module) (@INC contains: /etc/perl /usr/local/lib/x86_64-linux-gnu/perl/5.26.1 /usr/local/share/perl/5.26.1 /usr/lib/x86_64-linux-gnu/perl5/5.26 /usr/share/perl5 /usr/lib/x86_64-linux-gnu/perl/5.26 /usr/share/perl/5.26 /usr/local/lib/site_perl /usr/lib/x86_64-linux-gnu/perl-base) at /usr/share/perl5/Debconf/FrontEnd/Readline.pm line 7.)

debconf: falling back to frontend: Teletype

Configuring mysql-apt-config

----------------------------

MySQL APT Repo features MySQL Server along with a variety of MySQL components. You may select the appropriate product to choose the version

that you wish to receive.

Once you are satisfied with the configuration then select last option 'Ok' to save the configuration, then run 'apt-get update' to load

package list. Advanced users can always change the configurations later, depending on their own needs.

1. MySQL Server & Cluster (Currently selected: mysql-8.0) 3. MySQL Preview Packages (Currently selected: Disabled)

2. MySQL Tools & Connectors (Currently selected: Enabled) 4. Ok

Which MySQL product do you wish to configure? 1

This configuration program has determined that mysql-8.0 is configured on your system, and has highlighted the most appropriate repository

package. If you are not sure which version to install, do not change the auto-selected version. Advanced users can always change the

version as needed later. Note that MySQL Cluster also contains MySQL Server.

1. mysql-5.7 2. mysql-8.0 3. mysql-cluster-7.5 4. mysql-cluster-7.6 5. mysql-cluster-8.0 6. None

Which server version do you wish to receive? 2

MySQL APT Repo features MySQL Server along with a variety of MySQL components. You may select the appropriate product to choose the version

that you wish to receive.

Once you are satisfied with the configuration then select last option 'Ok' to save the configuration, then run 'apt-get update' to load

package list. Advanced users can always change the configurations later, depending on their own needs.

1. MySQL Server & Cluster (Currently selected: mysql-8.0) 3. MySQL Preview Packages (Currently selected: Disabled)

2. MySQL Tools & Connectors (Currently selected: Enabled) 4. Ok

Which MySQL product do you wish to configure? 4

Warning: apt-key should not be used in scripts (called from postinst maintainerscript of the package mysql-apt-config)

OK

apt-get update #更新mysql源

注意看一下是否更新成功,有时候会出现connect time out,多试几次就可以了

apt-get install mysql-server #安装mysql

输入密码 123456

确认密码 123456

选 1. Use Strong Password Encryption (RECOMMENDED) #选择1强密码加密

安装完成后,官网说直接使用service就可以启动,service mysql start,但是我这里报找不到这个service启动脚本。

因为在/etc/init.d/目录里没有这个mysql的启动命令

使用mysqld来启动,直接使用mysqld命令启动,报错不允许使用root用户执行

[Server] Fatal error: Please read "Security" section of the manual to find out how to run mysqld as root!

使用mysql用户执行

mysqld --user=mysql & #启动并后台运行

ps aux | grep mysql #查看已经启动了mysqld

kill 进程号可以停止mysql服务

mysql -uroot -p

输入密码123456

show databases; #查看现有的库

root@7c609eaf61d3:/etc/init.d# mysql -uroot -p

Enter password:

Welcome to the MySQL monitor. Commands end with ; or g.

Your MySQL connection id is 8

Server version: 8.0.21 MySQL Community Server - GPL

Copyright (c) 2000, 2020, 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> show databases;

+--------------------+

| Database |

+--------------------+

| information_schema |

| mysql |

| performance_schema |

| sys |

+--------------------+

4 rows in set (0.00 sec)

mysql> exit #退出msyql

whereis mysql #查看mysql安装的位置

到此已经成功安装上8.0.21 MySQL

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值