1、download mysql rpm package
http://dev.mysql.com/downloads/mysql/5.5.html#downloads
server:MySQL-server-5.5.32-1.linux2.6.i386.rpm
client:MySQL-client-5.5.32-1.linux2.6.i386.rpm
2、add group and user
[root@localhost soft]# groupadd mysql
[root@localhost soft]# useradd mysql -g mysql
3、install server
判断是否安装mysql
[root@master soft]# rpm -qa | grep MySQL
[root@master soft]# rpm -qa | grep mysql
如果安装过先卸载
[root@master soft]# rpm -qa | grep mysql
mysql-libs-5.1.66-2.el6_3.i686
[root@master soft]# rpm -e mysql-libs-5.1.66-2.el6_3.i686
error: Failed dependencies:
libmysqlclient.so.16 is needed by (installed) postfix-2:2.6.6-2.2.el6_1.i686
libmysqlclient.so.16(libmysqlclient_16) is needed by (installed) postfix-2:2.6.6-2.2.el6_1.i686
mysql-libs is needed by (installed) postfix-2:2.6.6-2.2.el6_1.i686
[root@master soft]# rpm -e --nodeps mysql-libs-5.1.66-2.el6_3.i686
[root@localhost soft]# pwd
/usr/soft
[root@localhost soft]# rpm -ivh MySQL-server-5.5.32-1.linux2.6.i386.rpm
Preparing... ########################################### [100%]
1:MySQL-server ########################################### [100%]
PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
To do so, start the server, then issue the following commands:
/usr/bin/mysqladmin -u root password 'new-password'
/usr/bin/mysqladmin -u root -h localhost password 'new-password'
Alternatively you can run:
/usr/bin/mysql_secure_installation
which will also give you the option of removing the test
databases and anonymous user created by default. This is
strongly recommended for production servers.
See the manual for more instructions.
Please report any problems with the /usr/bin/mysqlbug script!
[root@localhost soft]#
4、install client
[root@localhost bin]# cd /usr/soft/
[root@localhost soft]# ls
apache-ant-1.9.1 apache-nutch-2.1-src.tar.gz jdk1.6.0_45 MySQL-client-5.5.32-1.linux2.6.i386.rpm node-v0.6.18 vmware-tools-distrib
apache-ant-1.9.1-bin.tar.gz database jdk-6u45-linux-i586.bin MySQL-server-5.5.32-1.linux2.6.i386.rpm node-v0.6.18.tar.gz
[root@localhost soft]# rpm -ivh MySQL-client-5.5.32-1.linux2.6.i386.rpm
Preparing... ########################################### [100%]
1:MySQL-client ########################################### [100%]
[root@localhost soft]#
5、start mysql server and modify password
[root@localhost /]# /etc/init.d/mysql start
Starting MySQL....... [确定]
/usr/bin/mysqladmin -u root password 'root'
6、test
[root@localhost /]# cd /
[root@localhost /]# netstat -nat | grep 3306
tcp 0 0 0.0.0.0:3306 0.0.0.0:* LISTEN
[root@localhost /]# mysql -uroot -proot
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 7
Server version: 5.5.32 MySQL Community Server (GPL)
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>
7、create other user
mysql> insert into user(Host,User,Password) values ('%','mysql',password('mysql'));
Query OK, 1 row affected, 3 warnings (0.00 sec)
grant all privileges on nutch.* to mysql@'%';
mysql> flush privileges;
8、修改配置文件及默认编码
拷贝配置文件
[root@localhost ~]# cd /usr/share/mysql/
[root@localhost mysql]# cp -r my-medium.cnf /etc/my.cnf
修改配置文件:
在[client]节点下增加配置项:default-character-set = utf8
在[mysqld]节点下增加配置项:
character_set_server = utf8
datadir = /var/lib/mysql