1) 安装 MySql
sudo apt-get install mysql-server
sounion@ubuntu:/usr/local/src$ sudo apt-get install mysql-server
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following package was automatically installed and is no longer required:
tdb-tools
Use 'apt-get autoremove' to remove them.
The following extra packages will be installed:
libdbd-mysql-perl libdbi-perl libhtml-template-perl libmysqlclient18
libnet-daemon-perl libplrpc-perl libterm-readkey-perl mysql-client-5.5
mysql-client-core-5.5 mysql-common mysql-server-5.5 mysql-server-core-5.5
Suggested packages:
libipc-sharedcache-perl tinyca mailx
The following NEW packages will be installed:
libdbd-mysql-perl libdbi-perl libhtml-template-perl libmysqlclient18
libnet-daemon-perl libplrpc-perl libterm-readkey-perl mysql-client-5.5
mysql-client-core-5.5 mysql-common mysql-server mysql-server-5.5
mysql-server-core-5.5
0 upgraded, 13 newly installed, 0 to remove and 565 not upgraded.
Need to get 27.2 MB of archives.
After this operation, 97.5 MB of additional disk space will be used.
Do you want to continue [Y/n]? y
Get:1 http://mirrors.sohu.com/ubuntu/ precise-updates/main mysql-common all 5.5.35-0ubuntu0.12.04.2 [13.0 kB]
Get:2 http://mirrors.sohu.com/ubuntu/ precise-updates/main libmysqlclient18 amd64 5.5.35-0ubuntu0.12.04.2 [945 kB]
Get:3 http://mirrors.sohu.com/ubuntu/ precise/main libnet-daemon-perl all 0.48-1 [43.1 kB]
Get:4 http://mirrors.sohu.com/ubuntu/ precise/main libplrpc-perl all 0.2020-2 [36.0 kB]
Get:5 http://mirrors.sohu.com/ubuntu/ precise/main libdbi-perl amd64 1.616-1build2 [849 kB]
Get:6 http://mirrors.sohu.com/ubuntu/ precise/main libdbd-mysql-perl amd64 4.020-1build2 [106 kB]
Get:7 http://mirrors.sohu.com/ubuntu/ precise-updates/main mysql-client-core-5.5 amd64 5.5.35-0ubuntu0.12.04.2 [1,923 kB]
Get:8 http://mirrors.sohu.com/ubuntu/ precise/main libterm-readkey-perl amd64 2.30-4build3 [28.6 kB]
Get:9 http://mirrors.sohu.com/ubuntu/ precise-updates/main mysql-client-5.5 amd64 5.5.35-0ubuntu0.12.04.2 [8,292 kB]
Get:10 http://mirrors.sohu.com/ubuntu/ precise-updates/main mysql-server-core-5.5 amd64 5.5.35-0ubuntu0.12.04.2 [6,073 kB]
Get:11 http://mirrors.sohu.com/ubuntu/ precise-updates/main mysql-server-5.5 amd64 5.5.35-0ubuntu0.12.04.2 [8,820 kB]
Get:12 http://mirrors.sohu.com/ubuntu/ precise/main libhtml-template-perl all 2.10-1 [65.0 kB]
Get:13 http://mirrors.sohu.com/ubuntu/ precise-updates/main mysql-server all 5.5.35-0ubuntu0.12.04.2 [11.2 kB]
Fetched 27.2 MB in 26s (1,044 kB/s)
Preconfiguring packages ...
Selecting previously unselected package mysql-common.
(Reading database ... 199720 files and directories currently installed.)
Unpacking mysql-common (from .../mysql-common_5.5.35-0ubuntu0.12.04.2_all.deb) ...
Selecting previously unselected package libmysqlclient18.
Unpacking libmysqlclient18 (from .../libmysqlclient18_5.5.35-0ubuntu0.12.04.2_amd64.deb) ...
Selecting previously unselected package libnet-daemon-perl.
Unpacking libnet-daemon-perl (from .../libnet-daemon-perl_0.48-1_all.deb) ...
Selecting previously unselected package libplrpc-perl.
Unpacking libplrpc-perl (from .../libplrpc-perl_0.2020-2_all.deb) ...
Selecting previously unselected package libdbi-perl.
Unpacking libdbi-perl (from .../libdbi-perl_1.616-1build2_amd64.deb) ...
Selecting previously unselected package libdbd-mysql-perl.
Unpacking libdbd-mysql-perl (from .../libdbd-mysql-perl_4.020-1build2_amd64.deb) ...
Selecting previously unselected package mysql-client-core-5.5.
Unpacking mysql-client-core-5.5 (from .../mysql-client-core-5.5_5.5.35-0ubuntu0.12.04.2_amd64.deb) ...
Selecting previously unselected package libterm-readkey-perl.
Unpacking libterm-readkey-perl (from .../libterm-readkey-perl_2.30-4build3_amd64.deb) ...
Selecting previously unselected package mysql-client-5.5.
Unpacking mysql-client-5.5 (from .../mysql-client-5.5_5.5.35-0ubuntu0.12.04.2_amd64.deb) ...
Selecting previously unselected package mysql-server-core-5.5.
Unpacking mysql-server-core-5.5 (from .../mysql-server-core-5.5_5.5.35-0ubuntu0.12.04.2_amd64.deb) ...
Processing triggers for man-db ...
Setting up mysql-common (5.5.35-0ubuntu0.12.04.2) ...
Selecting previously unselected package mysql-server-5.5.
(Reading database ... 200097 files and directories currently installed.)
Unpacking mysql-server-5.5 (from .../mysql-server-5.5_5.5.35-0ubuntu0.12.04.2_amd64.deb) ...
Selecting previously unselected package libhtml-template-perl.
Unpacking libhtml-template-perl (from .../libhtml-template-perl_2.10-1_all.deb) ...
Selecting previously unselected package mysql-server.
Unpacking mysql-server (from .../mysql-server_5.5.35-0ubuntu0.12.04.2_all.deb) ...
Processing triggers for man-db ...
Processing triggers for ureadahead ...
Setting up libmysqlclient18 (5.5.35-0ubuntu0.12.04.2) ...
Setting up libnet-daemon-perl (0.48-1) ...
Setting up libplrpc-perl (0.2020-2) ...
Setting up libdbi-perl (1.616-1build2) ...
Setting up libdbd-mysql-perl (4.020-1build2) ...
Setting up mysql-client-core-5.5 (5.5.35-0ubuntu0.12.04.2) ...
Setting up libterm-readkey-perl (2.30-4build3) ...
Setting up mysql-client-5.5 (5.5.35-0ubuntu0.12.04.2) ...
Setting up mysql-server-core-5.5 (5.5.35-0ubuntu0.12.04.2) ...
Setting up mysql-server-5.5 (5.5.35-0ubuntu0.12.04.2) ...
140419 7:59:41 [Warning] Using unique option prefix key_buffer instead of key_buffer_size is deprecated and will be removed in a future release. Please use the full name instead.
mysql start/running, process 7545
Setting up libhtml-template-perl (2.10-1) ...
Setting up mysql-server (5.5.35-0ubuntu0.12.04.2) ...
Processing triggers for libc-bin ...
ldconfig deferred processing now taking place
2) Ubuntu 12.04版本中安装时,会弹出对话框要求输入MySql root password。输入之。
在对话框中输入管理员密码后,下述命令似乎不能再更改该密码。
#sudo /usr/bin/mysqladmin -u root password '123'
3)修改MySql 配置文件,增加红色的配置部分。
#sudo gedit /etc/mysql/my.cnf &
[mysqld]
#
# * Basic Settings
#
user = mysql
pid-file = /var/run/mysqld/mysqld.pid
socket = /var/run/mysqld/mysqld.sock
port = 3306
basedir = /usr
datadir = /var/lib/mysql
tmpdir = /tmp
# ignore upper/lower cases
lower_case_table_name=1
lc-messages-dir = /usr/share/mysql
[mysql]
#no-auto-rehash # faster start of mysql but no tab completition
default-character-set = gbk
4)链接MySql
#mysql -u root -p
sounion@ubuntu:/etc/mysql$ mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 44
Server version: 5.5.35-0ubuntu0.12.04.2 (Ubuntu)
Copyright (c) 2000, 2013, 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>
看到以上mysql>提示符表示已经安装完成。