Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1364548
  • 博文数量: 704
  • 博客积分: 10140
  • 博客等级: 上将
  • 技术积分: 6230
  • 用 户 组: 普通用户
  • 注册时间: 2010-07-15 20:41
文章分类

全部博文(704)

文章存档

2013年(1)

2012年(16)

2011年(536)

2010年(151)

分类:

2011-01-15 21:45:52

安装MySQL

要安装 MySQL,可以在终端提示符后运行下列命令:

sudo apt-get install mysql-server mysql-client #中途会让你输入一次root用户密码
sudo apt-get install php5-mysql  #安装php5-mysql 是将php和mysql连接起来

一旦安装完成,MySQL 服务器应该自动启动。

sudo start mysql #手动的话这样启动
sudo stop mysql #手动停止

当你修改了配置文件後,你需要重启 mysqld 才能使这些修改生效。

要想检查 mysqld 进程是否已经开启,可以使用下面的命令:

pgrep mysqld

如果进程开启,这个命令将会返回该进程的 id。

[]文件结构

MySQL配置文件:/etc/mysql/my.cnf ,其中指定了数据文件存放路径

datadir         = /var/lib/mysql

如果你创建了一个名为 test 的数据库,那么这个数据库的数据会存放到 /var/lib/mysql/test 目录下。

[]进入MySQL

mysql -uroot -p 

(输入mysql的root密码)

qii@ubuntu:~$ mysql -u root -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 37
Server version: 5.1.41-3ubuntu12.3 (Ubuntu)

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> 

修改 MySQL 的管理员密码:

sudo mysqladmin -u root password newpassword

[]简单的操作

显示数据库:

mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
+--------------------+
2 rows in set (0.00 sec)

[]phpmyadmin管理

用随便一个支持PHP的web服务器(如、、),下载phpmyadmin,装之。

sudo apt-get install phpmyadmin  #注意这是安装到/usr/share/phpmyadmin
阅读(699) | 评论(1) | 转发(0) |
给主人留下些什么吧!~~

chinaunix网友2011-03-09 13:35:50

很好的, 收藏了 推荐一个博客,提供很多免费软件编程电子书下载: http://free-ebooks.appspot.com