linux上mysql的安装(使用rpm文件)
一、 卸载 mysql
????? [root@ssoldap ~]# rpm -qa | grep -i mysql
????? MySQL-client-5.5.16-1.linux2.6
????? MySQL-server-5.5.16-1.linux2.6
????? [root@ssoldap ~]# rpm -ev MySQL-client-5.5.16-1.linux2.6 MySQL-server-5.5.16-1.linux2.6
????? [root@ssoldap ~]# rpm -qa | grep -i mysql
????? 以上的命令一目了然,注意在卸载完成之后需要删除配置文件/etc/my.cnf和数据库文件/var/lib/mysql。
二、安装mysql服务端程序
1、? 先下载下面两个rpm包,这里主要是以rpm安装方式进行讲解。
????? MySQL-client-5.5.16-1.linux2.6.i386.rpm
????? MySQL-server-5.5.16-1.linux2.6 .i386.rpm
2、? 安装如下图所示:
????? [root@ssoldap ~]# rpm -ivh MySQL-server-5.5.16-1.linux2.6.i386.rpm
3、? 服务器端安装完成之后,在/usr/share/mysql目录中会生成一个mysql启动脚本mysql.server和一些示例配置文件,其中有一个配置文件my-medium.cnf,因为mysql安装完成之后就默认成为系统服务,所以这里需要将配置文件放在系统服务的相关目录下,需要做如下操作:
4、? [root@ssoldap ~]# cp /usr/share/mysql/my-medium.cnf /etc/my.cnf
?????? 改名为my.cnf作为mysql配置文件。
5、? 下面看看如何启动和停止mysql服务,如下图所示:
????? [root@ssoldap ~]# ps -ef | grep mysql?
????? root 17791 4323 0 22:58 pts/1 00:00:00 grep mysql
????? [root@ssoldap ~]# service mysql start
????? Starting MySQL.?????????????????????????????????????? [OK]
????? [root@ssoldap ~]# service mysql stop
????? Shutting down MySQL..??????????????????????????? [OK]
????? 到此mysql服务端的安装配置完成。
三、安装mysql客户端程序
6、? 安装命令如同服务器一样:
????? [root@ssoldap ~] # rpm -ivh MySQL-client-5.5.8-1.linux2.6.i386.rpm?
7、? mysql安装 完 后目录结构如下:
????? [root@ssoldap ~] # ls /usr/bin/mysql*
????? /usr/bin/mysql?????????????????????? /usr/bin/mysqlhotcopy
????? /usr/bin/mysqlaccess???????????????? /usr/bin/mysqlimport
????? /usr/bin/mysqlaccess.conf??????????? /usr/bin/mysql_install_db
????? /usr/bin/mysqladmin????????????????? /usr/bin/mysql_plugin
????? /usr/bin/mysqlbinlog???????????????? /usr/bin/mysql_secure_installation
????? /usr/bin/mysqlbug??????????????????? /usr/bin/mysql_setpermission
????? /usr/bin/mysqlcheck????????????????? /usr/bin/mysqlshow
????? /usr/bin/mysql_convert_table_format? /usr/bin/mysqlslap
????? /usr/bin/mysqld_multi??????????????? /usr/bin/mysqltest
????? /usr/bin/mysqld_safe???????????????? /usr/bin/mysql_tzinfo_to_sql
????? /usr/bin/mysqldump?????????????????? /usr/bin/mysql_upgrade
????? /usr/bin/mysqldumpslow?????????????? /usr/bin/mysql_waitpid
????? /usr/bin/mysql_find_rows???????????? /usr/bin/mysql_zap
????? /usr/bin/mysql_fix_extensions
8、? 服务器程序为/usr/sbin/mysqld
9、? 数据目录为/var/lib/mysql,默认情况下要日志文件都存放在/var/lib/mysql下,如果要改变其存放位置,可以通过更改/etc/my.cnf配置文件实现。
四、登录mysql数据库
10、? 默认安装完成之后mysql的用户名为root,密码为空,所以如果安装成功后登录应该如下图所示:
????? [root@ssoldap ~]# mysql
????? Welcome to the MySQL monitor.? Commands end with ; or \g.
????? Your MySQL connection id is 44 to server version: 5.5.16-log
????? Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
????? mysql> show databases;
????? +--------------------+
????? | Database?????????? |
????? +--------------------+
????? | information_schema |
????? | mysql????????????? |
????? | openmeetings?????? |
????? | openmmetings?????? |
????? | performance_schema |
????? | test?????????????? |
????? | zflive???????????? |
????? | zfopenmeetings???? |
????? +--------------------+
????? 8 rows in set (0.00 sec)
11、? 如上图所示就已经成功登录mysql数据库了。
12、? 修改mysql编码
????? [root@ssoldap ~]# vi /ect/my.cnf
????? [client]
????? default-character-set=utf8
????? [mysqld]
????? default-character-set=utf8
????? init_connect='SET NAMES utf8' 或者
????? character-set-server=utf8??? //这一项决定了除client,mydqld以外的其它项的编码,不同版本选择不同