Mysql安装

来源:互联网 发布:linux 不支持ext4 编辑:程序博客网 时间:2024/04/30 13:26

1.查看系统中是否以rpm包安装的mysql
rpm -qa | grep -i mysql 
MySQL-server-5.6.21-1.linux_glibc2.5.i386


2.卸载Mysql
 rpm -e MySQL-server-5.6.21-1.linux_glibc2.5.i386


3.安装mysql
31.前期的一些准备说明,参考:
MySQL 发展史
http://blog.csdn.net/tianlesoftware/article/details/6999245


Mysql 不同版本 说明
http://blog.csdn.net/tianlesoftware/article/details/6723117


MySQL 分为Community Server 和 Enterprise Edition。 其中Community Server 可以直接从mysql 的官网下载。Enterprice Edition 只能从Oracle edelivery上下载。


官方文档上有关MySQL安装文件类型说明:
http://dev.mysql.com/doc/refman/5.5/en/index.html


3.3下载Mysql社区版
下载地址http://dev.mysql.com/downloads/mysql/
(1)MySQL的安装包有很多个,作用也不同,在大多数情况下,只需要安装MySQL-server 和 MySQL-client,其他的包根据需要来安装。
 
(2)The server RPM places data underthe /var/lib/mysql directory. The RPM also creates a login accountfor a user named mysql (if one does not exist) to use for running theMySQL server, and creates the appropriate entries in /etc/init.d/ tostart the server automatically at boot time. (This means that if you haveperformed a previous installation and have made changes to its startup script,you may want to make a copy of the script so that you do not lose it when youinstall a newer RPM.) 
 
(3)During RPM installation, a usernamed mysql and a group named mysql are created on thesystem. This is done using the useradd, groupadd,and usermod commands. Those commands require appropriateadministrative privileges, which is required for locally managed users andgroups (as listed in the /etc/passwd and /etc/groupfiles) by theRPM installation process being run by root.
       --在MySQL 安装时,会创建mysql 用户和mysql组。
 
(4)MySQL 的相关目录说明
/usr/bin : Client programs and scripts    -- mysqladmin mysqldump等命令
/usr/sbin:  The mysqld server
/var/lib/mysql:Log files, databases  --这个目录就是数据库的目录
/usr/share/info:Manual in Info format
/usr/share/man:Unix manual pages
/usr/include/mysql:Include (header) files
/usr/lib/mysql:Libraries
/usr/share/mysql : Miscellaneous support files,including error messages, character set files, sample configuration files, SQLfor database installation
             --mysql.server命令及配置文件
/usr/share/sql-bench: Benchmarks
/etc/rc.d/init.d/: 启动脚本文件mysql的目录


3.4安装Mysql
MySQL的安装包有很多个,作用也不同,在大多数情况下,只需要安装MySQL-server 和 MySQL-client,其他的包根据需要来安装
rpm -ivh MySQL-server-5.6.21-1.linux_glibc2.5.x86_64.rpm 
(1)如果遇到conflicts with file from package mysql-libs
这表示有冲突的包
解决思路,先移除冲突的libs包,在进行安装 
yum -y remove mysql-libs-5.1.52* 
(2)如果遇到error failed dependencies libncurses.so.5 is needed by mysql-client
则有可能server安装的版本不对。如64位操作系统,装了32位的server版本


接着安装客户端rpm -ivh MySQL-client-5.5.15-1.rhel5.x86_64.rpm,否则无法登陆


4.使用数据库
4.1 查看在时创建的mysql用户和mysql group:
[root@rac2 bin]# cat /etc/passwd|grep mysql
mysql:x:103:106:MySQLserver:/var/lib/mysql:/bin/bash
[root@rac2 bin]# cat /etc/group | grepmysql
mysql:x:106:


4.2 连接MySQL
--连接MySQL 报错:
[root@rac2 software]# mysql
ERROR 2002 (HY000): Can't connect to localMySQL server through socket '/var/lib/mysql/mysql.sock' (2)
--启动MySQL 后,在连正常:
[root@rac2 ~]# /etc/init.d/mysql start
Starting MySQL...                                          [  OK  ]
--登陆失败
[root@rac2 init.d]# mysql
error: 'Access denied for user 'root'@'localhost' (using password: NO)'
--修改密码后,登陆成功
# /etc/init.d/mysql stop
# mysqld_safe --user=mysql --skip-grant-tables --skip-networking &
# mysql -u root mysql
mysql> UPDATE user SET Password=PASSWORD('newpassword') where USER='root';
mysql> FLUSH PRIVILEGES;
mysql> quit
# /etc/init.d/mysql restart
# mysql -uroot -p
Enter password: <输入新设的密码newpassword>
mysql>



转载自:http://blog.csdn.net/tianlesoftware/article/details/7001808

0 0