赞
踩
目录
Ubuntu安装MySQL一般是用作服务端,可以只安装服务端。
- # 更新软件源
- root@ubuntu:~# apt-get update
-
- # 搜索MySQL软件包
- root@ubuntu:~# apt-cache search mysql | grep ^mysql
- mysql-client - MySQL database client (metapackage depending on the latest version)
- mysql-client-5.7 - MySQL database client binaries
- mysql-client-core-5.7 - MySQL database core client binaries
- mysql-common - MySQL database common files, e.g. /etc/mysql/my.cnf
- mysql-server - MySQL database server (metapackage depending on the latest version)
- mysql-server-5.7 - MySQL database server binaries and system database setup
- mysql-server-core-5.7 - MySQL database server binaries
- mysql-mmm-agent - Multi-Master Replication Manager for MySQL - agent daemon
- mysql-mmm-common - Multi-Master Replication Manager for MySQL - common files
- mysql-mmm-monitor - Multi-Master Replication Manager for MySQL - monitoring daemon
- mysql-mmm-tools - Multi-Master Replication Manager for MySQL - tools
- mysql-sandbox - Install and set up one or more MySQL server instances easily
- mysql-source-5.7 - MySQL source
- mysql-testsuite - MySQL regression tests
- mysql-testsuite-5.7 - MySQL 5.7 testsuite
- mysql-utilities - collection of scripts for managing MySQL servers
- mysql-workbench - MySQL Workbench - a visual database modeling, administration and queuing tool
- mysql-workbench-data - MySQL Workbench -- architecture independent data
- mysqltcl - interface to the MySQL database for the Tcl language
- mysqltuner - high-performance MySQL tuning script

从以上搜索结果可知有2个版本,一个是5.7版本,一个没有版本号,没有版本号的是最新版本。
此处安装最新版本。
root@ubuntu:~# apt-get install mysql-server -y
安装过程中会配置root账号的密码:
root@ubuntu:~# apt-get install mysql-client -y
root@ubuntu:~# apt-get install libmysql++-dev -y
- root@ubuntu:~# netstat -tap | grep mysql
- tcp 0 0 localhost:mysql *:* LISTEN 3997/mysqld
-
- # 也可以检测mysql进程
- root@ubuntu:~# ps aux | grep mysql
- mysql 3997 0.3 3.3 1114692 136788 ? Ssl 23:15 0:03 /usr/sbin/mysqld
- root 9104 0.0 0.0 14220 936 pts/0 S+ 23:31 0:00 grep --color=auto mysql
使用命令"mysql -u root -p"连接
也可以使用命令"mysql -u root -p密码"连接MySQL,注意:-p后直接跟密码,没有空格
- root@ubuntu:~# mysql -u root -p
- Enter password:
- Welcome to the MySQL monitor. Commands end with ; or \g.
- Your MySQL connection id is 11
- Server version: 5.7.33-0ubuntu0.16.04.1 (Ubuntu)
-
- Copyright (c) 2000, 2021, Oracle and/or its affiliates.
-
- 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>
至此,安装完成。
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。