后续所有的运行均在ubuntu下,我使用的ubuntu是14.04
1. 安装
ubuntu 下可以直接用命令
sudo apt-get install mysql-server,注意在这过程中会需要输入用户名 密码
这里不多做介绍,具体可看:http://www.cnblogs.com/wuhou/archive/2008/09/28/1301071.html
2. 配置
(1) /etc/mysql/my.cnf
(2) mysqladmin 命令
可以使用
mysqladmin -u root -p version 查看服务器状态
wangfengbo@ubuntu:~$ mysqladmin -u root -p version
Enter password:
mysqladmin Ver 8.42 Distrib 5.5.46, for debian-linux-gnu on i686
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.
Server version5.5.46-0ubuntu0.14.04.2
Protocol version10
Connection Localhost via UNIX socket
UNIX socket /var/run/mysqld/mysqld.sock
Uptime: 2 hours 19 min 3 sec
Threads: 5 Questions: 117 Slow queries: 0 Opens: 48 Flush tables: 1 Open tables: 41 Queries per second avg: 0.014
wangfengbo@ubuntu:~$ mysqladmin
mysqladmin -u root -p variables 检查运行的服务器中所有的配置选项
很重要的两个: datadir have_innodb
wangfengbo@ubuntu:~$ mysqladmin -u root -p variables | grep datadir //here tell us where the data locate
Enter password:
| datadir | /var/lib/mysql/ |
wangfengbo@ubuntu:~$ mysqladmin -u root -p variables | grep have_innodb //here tell us what type of storage engine we use
Enter password:
| have_innodb | YES
主要的两种存储引擎 Innodb he MyISAM 对于数据库 我们建议使用 Innodb
若服务器代码中包含 innodb, 我们将其设置为默认存储引擎,若不设置,服务器默认使用MyISAM,修改方法: /etc/mysql/my.cnf 文件的mysqld一节中
增加 default-storage-engine=INNODB一行内容
[mysqld]
default-strorage-engine=INNODB // add this new one, youknow
datadir=/va/lib/mysql
(3) 修改密码
mysqladmin -u root -p password
3. sql语句
(1)SHOW DATABASES; // you must add ';' at the end of each sql command
(2)SELECT DELETE