注册 登录  
 加关注
   显示下一条  |  关闭
温馨提示!由于新浪微博认证机制调整,您的新浪微博帐号绑定已过期,请重新绑定!立即重新绑定新浪微博》  |  关闭

拥有自己的梦想,跟随心的召唤

平凡是福

 
 
 

日志

 
 

Ubuntu 11.04 通过 apt 安装 Mysql 5.1 的全过程记录  

2011-12-01 14:04:38|  分类: Ubuntu |  标签: |举报 |字号 订阅

  下载LOFTER 我的照片书  |
Ubuntu11.04通过apt安装Mysql5.1的全过程记录 2011-12-01
1) $ sudo apt-get install mysql-server
 Reading package lists... Done
Building dependency tree
Reading state information... Done
The following extra packages will be installed:
libdbd-mysql-perl libdbi-perl libhtml-template-perl libmysqlclient16 libnet-daemon-perl
libplrpc-perl mysql-client-5.1 mysql-client-core-5.1 mysql-common mysql-server-5.1
mysql-server-core-5.1
Suggested packages:
libipc-sharedcache-perl tinyca mailx
The following NEW packages will be installed:
libdbd-mysql-perl libdbi-perl libhtml-template-perl libmysqlclient16 libnet-daemon-perl
libplrpc-perl mysql-client-5.1 mysql-client-core-5.1 mysql-common mysql-server
mysql-server-5.1 mysql-server-core-5.1
0 upgraded, 12 newly installed, 0 to remove and 28 not upgraded.
Need to get 23.9 MB of archives.
After this operation, 61.1 MB of additional disk space will be used.
Do you want to continue [Y/n]? y
Get:1 http://cn.archive.ubuntu.com/ubuntu/ natty/main mysql-common all 5.1.54-1ubuntu4 [12.2 kB]
Get:2 http://cn.archive.ubuntu.com/ubuntu/ natty/main mysql-common all 5.1.54-1ubuntu4 [12.2 kB]
Get:3 http://cn.archive.ubuntu.com/ubuntu/ natty/main libnet-daemon-perl all 0.43-1 [46.9 kB]
Get:4 http://cn.archive.ubuntu.com/ubuntu/ natty/main libplrpc-perl all 0.2020-2 [36.0 kB]
Get:5 http://cn.archive.ubuntu.com/ubuntu/ natty/main libdbi-perl amd64 1.612-1 [846 kB]
Get:6 http://cn.archive.ubuntu.com/ubuntu/ natty/main libmysqlclient16 amd64 5.1.54-1ubuntu4 [1869 kB]
Get:7 http://cn.archive.ubuntu.com/ubuntu/ natty/main libmysqlclient16 amd64 5.1.54-1ubuntu4 [1869 kB]
Get:8 http://cn.archive.ubuntu.com/ubuntu/ natty/main libdbd-mysql-perl amd64 4.016-1 [140 kB]
Get:9 http://cn.archive.ubuntu.com/ubuntu/ natty/main mysql-client-core-5.1 amd64 5.1.54-1ubuntu4 [102 kB]
Get:10 http://cn.archive.ubuntu.com/ubuntu/ natty/main mysql-client-5.1 amd64 5.1.54-1ubuntu4 [9370 kB]
Get:11 http://cn.archive.ubuntu.com/ubuntu/ natty/main mysql-client-5.1 amd64 5.1.54-1ubuntu4 [9370 kB]
Get:12 http://cn.archive.ubuntu.com/ubuntu/ natty/main mysql-server-core-5.1 amd64 5.1.54-1ubuntu4 [4976 kB]
Get:13 http://cn.archive.ubuntu.com/ubuntu/ natty/main mysql-server-5.1 amd64 5.1.54-1ubuntu4 [6386 kB]
Get:14 http://cn.archive.ubuntu.com/ubuntu/ natty/main mysql-server-5.1 amd64 5.1.54-1ubuntu4 [6386 kB]
Get:15 http://cn.archive.ubuntu.com/ubuntu/ natty/main mysql-server-5.1 amd64 5.1.54-1ubuntu4 [6386 kB]
Get:16 http://cn.archive.ubuntu.com/ubuntu/ natty/main libhtml-template-perl all 2.9-2 [67.1 kB]
Get:17 http://cn.archive.ubuntu.com/ubuntu/ natty/main mysql-server all 5.1.54-1ubuntu4 [6828 B]
...

2) 设置root帐号的密码
Ubuntu 11.04 通过 apt 安装 Mysql 5.1 的全过程记录 - rongjih - 拥有自己的梦想,跟随心的召唤
 
Ubuntu 11.04 通过 apt 安装 Mysql 5.1 的全过程记录 - rongjih - 拥有自己的梦想,跟随心的召唤
 
3) 安装过程的细节
 Selecting previously deselected package mysql-common.
(Reading database ... 50200 files and directories currently installed.)
Unpacking mysql-common (from .../mysql-common_5.1.54-1ubuntu4_all.deb) ...
Selecting previously deselected package libnet-daemon-perl.
Unpacking libnet-daemon-perl (from .../libnet-daemon-perl_0.43-1_all.deb) ...
Selecting previously deselected package libplrpc-perl.
Unpacking libplrpc-perl (from .../libplrpc-perl_0.2020-2_all.deb) ...
Selecting previously deselected package libdbi-perl.
Unpacking libdbi-perl (from .../libdbi-perl_1.612-1_amd64.deb) ...
Selecting previously deselected package libmysqlclient16.
Unpacking libmysqlclient16 (from .../libmysqlclient16_5.1.54-1ubuntu4_amd64.deb) ...
Selecting previously deselected package libdbd-mysql-perl.
Unpacking libdbd-mysql-perl (from .../libdbd-mysql-perl_4.016-1_amd64.deb) ...
Selecting previously deselected package mysql-client-core-5.1.
Unpacking mysql-client-core-5.1 (from .../mysql-client-core-5.1_5.1.54-1ubuntu4_amd64.deb) ...
Selecting previously deselected package mysql-client-5.1.
Unpacking mysql-client-5.1 (from .../mysql-client-5.1_5.1.54-1ubuntu4_amd64.deb) ...
Selecting previously deselected package mysql-server-core-5.1.
Unpacking mysql-server-core-5.1 (from .../mysql-server-core-5.1_5.1.54-1ubuntu4_amd64.deb) ...
Processing triggers for man-db ...
locale: Cannot set LC_CTYPE to default locale: No such file or directory
locale: Cannot set LC_MESSAGES to default locale: No such file or directory
locale: Cannot set LC_ALL to default locale: No such file or directory
Setting up mysql-common (5.1.54-1ubuntu4) ...
Selecting previously deselected package mysql-server-5.1.
(Reading database ... 50575 files and directories currently installed.)
Unpacking mysql-server-5.1 (from .../mysql-server-5.1_5.1.54-1ubuntu4_amd64.deb) ...
locale: Cannot set LC_CTYPE to default locale: No such file or directory
locale: Cannot set LC_MESSAGES to default locale: No such file or directory
locale: Cannot set LC_ALL to default locale: No such file or directory
Selecting previously deselected package libhtml-template-perl.
Unpacking libhtml-template-perl (from .../libhtml-template-perl_2.9-2_all.deb) ...
Selecting previously deselected package mysql-server.
Unpacking mysql-server (from .../mysql-server_5.1.54-1ubuntu4_all.deb) ...
Processing triggers for ureadahead ...
ureadahead will be reprofiled on next reboot
Processing triggers for man-db ...
locale: Cannot set LC_CTYPE to default locale: No such file or directory
locale: Cannot set LC_MESSAGES to default locale: No such file or directory
locale: Cannot set LC_ALL to default locale: No such file or directory
Setting up libnet-daemon-perl (0.43-1) ...
Setting up libplrpc-perl (0.2020-2) ...
Setting up libdbi-perl (1.612-1) ...
Setting up libmysqlclient16 (5.1.54-1ubuntu4) ...
Setting up libdbd-mysql-perl (4.016-1) ...
Setting up mysql-client-core-5.1 (5.1.54-1ubuntu4) ...
Setting up mysql-client-5.1 (5.1.54-1ubuntu4) ...
Setting up mysql-server-core-5.1 (5.1.54-1ubuntu4) ...
Setting up mysql-server-5.1 (5.1.54-1ubuntu4) ...
locale: Cannot set LC_CTYPE to default locale: No such file or directory
locale: Cannot set LC_MESSAGES to default locale: No such file or directory
locale: Cannot set LC_ALL to default locale: No such file or directory
mysql start/running, process 2201
Setting up libhtml-template-perl (2.9-2) ...
Setting up mysql-server (5.1.54-1ubuntu4) ...
Processing triggers for libc-bin ...
ldconfig deferred processing now taking place
dragon@usvm1104:~$
4) 登录mysql命令行测试一下
$ mysql -uroot -p
 Enter password: 
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 39
Server version: 5.1.54-1ubuntu4 (Ubuntu)

Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
This software comes with ABSOLUTELY NO WARRANTY. This is free software,
and you are welcome to modify and redistribute it under the GPL v2 license

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

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

mysql>
5) 开启Mysql的远程访问
MySQL在Ubuntu中默认安装后,只能在本机访问,如果要开启远程访问,需做以下两个步骤:
1、修改配置文件,注释掉bind-address限制;
$ sudo vi /etc/mysql/my.cnf
找到bind-address=127.0.0.1,把这一行注释掉
2、添加远程用户:
先在本机用root登录到mysql,然后用grant命令添加用户,如:
mysql> grant all privileges on 需要访问的db.* to 'newuser'@'%' indentified by 'password';
然后执行如下命令重启mysql即可:
$ service mysql restart

6) 其他参考
6-1) Mysql读取配置文件的顺序:/etc/my.cnf /etc/mysql/my.cnf /usr/etc/my.cnf ~/.my.cnf 
默认安装后只有 /etc/mysql/my.cnf 这个配置文件
6-2) 查看用户在本机执行Mysql命令的历史记录:~$ cat .mysql_history
6-3) 修改MySQL数据文件存放路径:
修改/etc/mysql/my.cnf的datadir=/var/lib/mysql,默认路径为/var/lib/mysql
6-4) 修改MySQL的默认端口:
修改/etc/mysql/my.cnf的port=3306,默认端口为3306
6-5) 修改 MySQL 的管理员密码:$ sudo mysqladmin -u root password newpassword
6-6) 安装客户端:$ sudo apt-get install mysql-client
6-7) 检查 mysqld 进程是否已经开启:$ pgrep mysqld,如果进程开启,这个命令将会返回该进程的 id
6-8) 检查 MySQL 服务器是否正在运行:
$ sudo netstat -tap | grep mysql
当您运行该命令时,您可以看到类似下面的行:
tcp 0 0 localhost.localdomain:mysql *:* LISTEN -
如果服务器不能正常运行,您可以通过下列命令启动它:$ sudo /etc/init.d/mysql restart
6-9) 查看mysql服务所使用的端口:$ sudo netstat -antup | grep mysql,将输出类似如下的信息
tcp        0      0 0.0.0.0:3306            0.0.0.0:*               LISTEN      682/mysqld

7) Ubuntu下彻底卸载通过 apt 安装的 mysql
1) 停止 mysql 服务
$ sudo service mysql stop

2) 删除 mysql
按顺序执行如下命令:
$ sudo apt-get autoremove --purge mysql-server
$ sudo apt-get remove mysql-server
$ sudo apt-get autoremove mysql-server
$ sudo apt-get remove mysql-common -->非常重要,避免mysql的服务随机启动
上面的其实有一些是多余的,建议还是按照顺序执行一遍,命令行历史记录参考如下:
 dragon@usvm1104:~$ sudo apt-get autoremove --purge mysql-server
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages will be REMOVED:
libdbd-mysql-perl* libdbi-perl* libhtml-template-perl* libmysqlclient16*
libnet-daemon-perl* libplrpc-perl* mysql-client-5.1* mysql-client-core-5.1* mysql-common*
mysql-server* mysql-server-5.1* mysql-server-core-5.1*
0 upgraded, 0 newly installed, 12 to remove and 28 not upgraded.
After this operation, 61.1 MB disk space will be freed.
Do you want to continue [Y/n]? y
perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
LANGUAGE = "en_US:en",
LC_ALL = (unset),
LANG = "en_US.UTF-8 UTF-8"
are supported and installed on your system.
perl: warning: Falling back to the standard locale ("C").
locale: Cannot set LC_CTYPE to default locale: No such file or directory
locale: Cannot set LC_MESSAGES to default locale: No such file or directory
locale: Cannot set LC_ALL to default locale: No such file or directory
(Reading database ... 50665 files and directories currently installed.)
Removing mysql-server ...
Removing mysql-server-5.1 ...
locale: Cannot set LC_CTYPE to default locale: No such file or directory
locale: Cannot set LC_MESSAGES to default locale: No such file or directory
locale: Cannot set LC_ALL to default locale: No such file or directory
locale: Cannot set LC_CTYPE to default locale: No such file or directory
locale: Cannot set LC_MESSAGES to default locale: No such file or directory
locale: Cannot set LC_ALL to default locale: No such file or directory
Purging configuration files for mysql-server-5.1 ...
locale: Cannot set LC_CTYPE to default locale: No such file or directory
locale: Cannot set LC_MESSAGES to default locale: No such file or directory
locale: Cannot set LC_ALL to default locale: No such file or directory
Removing mysql-client-5.1 ...
Removing libdbd-mysql-perl ...
Removing libdbi-perl ...
Removing libhtml-template-perl ...
Removing mysql-server-core-5.1 ...
Removing mysql-client-core-5.1 ...
Removing libmysqlclient16 ...
Purging configuration files for libmysqlclient16 ...
Removing libplrpc-perl ...
Removing libnet-daemon-perl ...
Removing mysql-common ...
Purging configuration files for mysql-common ...
dpkg: warning: while removing mysql-common, directory '/etc/mysql' not empty so not removed.
Processing triggers for man-db ...
locale: Cannot set LC_CTYPE to default locale: No such file or directory
locale: Cannot set LC_MESSAGES to default locale: No such file or directory
locale: Cannot set LC_ALL to default locale: No such file or directory
Processing triggers for ureadahead ...
ureadahead will be reprofiled on next reboot
Processing triggers for libc-bin ...
ldconfig deferred processing now taking place
dragon@usvm1104:~$ sudo apt-get remove mysql-server
Reading package lists... Done
Building dependency tree
Reading state information... Done
Package mysql-server is not installed, so not removed
0 upgraded, 0 newly installed, 0 to remove and 28 not upgraded.
dragon@usvm1104:~$ sudo apt-get autoremove mysql-server
Reading package lists... Done
Building dependency tree
Reading state information... Done
Package mysql-server is not installed, so not removed
0 upgraded, 0 newly installed, 0 to remove and 28 not upgraded.
dragon@usvm1104:~$ sudo apt-get remove mysql-common
Reading package lists... Done
Building dependency tree
Reading state information... Done
Package mysql-common is not installed, so not removed
0 upgraded, 0 newly installed, 0 to remove and 28 not upgraded.
dragon@usvm1104:~$
3) 清理残留数据
dpkg -l |grep ^rc|awk '{print $2}' |sudo xargs dpkg -P
  评论这张
 
阅读(2284)| 评论(0)
推荐 转载

历史上的今天

在LOFTER的更多文章

评论

<#--最新日志,群博日志--> <#--推荐日志--> <#--引用记录--> <#--博主推荐--> <#--随机阅读--> <#--首页推荐--> <#--历史上的今天--> <#--被推荐日志--> <#--上一篇,下一篇--> <#-- 热度 --> <#-- 网易新闻广告 --> <#--右边模块结构--> <#--评论模块结构--> <#--引用模块结构--> <#--博主发起的投票-->
 
 
 
 
 
 
 
 
 
 
 
 
 
 

页脚

网易公司版权所有 ©1997-2017