一、简易安装
#yum install -y mysql-server mysql mysql-devel
如果报安装包冲突:
file /usr/share/mysql/ukrainian/errmsg.sys from install of MySQL-server-5.5.18-1.rhel5.i386 conflicts with file from package mysql-libs-5.0.46-1.rhel5.i386
把安装包卸载就可以了
#yum -y remove mysql-libs-5.0.46-1.rhel5.i386 -y的意思就是不用询问是否remove
卸载之后,再安装MySQL成功
二、手动安装
1、先上传安装包
/opt/MySQL-server-4.0.16-0.i386.rpm
/opt/MySQL-client-4.0.16-0.i386.rpm(视情况而定,不一定要装)
2、给文件增加执行权限
#cd /opt/
切换到制定目录
#chmod a+x MySQL-server-4.0.16-0.i386.rpm
给文件增加执行权限
3、执行安装
#rpm -ivh MySQL-server-4.0.16-0.i386.rpm
如果安装过程报如下错误:
file /usr/share/mysql/charsets/cp1251.xml from install of MySQL-server-5.5.24-1.el6.i686 conflicts with file from package mysql-libs-5.1.52-1.el6_0.1.i686
file /usr/share/mysql/czech/errmsg.sys from install of MySQL-server-5.5.24-1.el6.i686 conflicts with file from package mysql-libs-5.1.52-1.el6_0.1.i686
原因由包冲突引起的!操作系统自带的某些包与mysql的包冲突,先移除冲突的libs包,在进行安装
#yum -y remove mysql-libs-5.1.52*
-y的意思就是不用询问是否remove
error: Failed dependencies:
libc.so.6 is needed by MySQL-server-community-5.1.63-1.rhel4.i386
libc.so.6(GLIBC_2.0) is needed by MySQL-server-community-5.1.63-1.rhel4.i386
libc.so.6(GLIBC_2.1) is needed by MySQL-server-community-5.1.63-1.rhel4.i386
#yum install libc.so.6
卸载完成之后,再次执行安装MySQL
#rpm -ivh MySQL-server-4.0.16-0.i386.rpm
三、设置root密码
新安装的mysql,默认用户root没有密码,需要设置密码
#/usr/bin/mysqladmin -u root -p ‘123456‘
如果报错,显示没有权限连接
mysqladmin: connect to server at ‘localhost‘ failed
error: ‘Access denied for user ‘root‘@‘localhost‘ (using password: YES)‘
解决方法:
先关闭数据库
#service mysqld stop
再以不检查安全的方法启动
# mysqld_safe --user=mysql --skip-grant-tables --skip-networking &
再登录
#mysql -u root mysql
再改密码
# UPDATE user SET Password=PASSWORD(‘newpassword‘) where USER=‘root‘ and host=‘root‘ or host=‘localhost‘;
#FLUSH PRIVILEGES;
重启mysql
#service mysqld restart
或者
#ps –aux | grep mysqld命令找出mysql的进程号
然后执行kill -9 进程号杀掉mysql进程
四、授权远程用户登录
新安装的mysql,默认只有本机才能登录,其他电脑通过网络登录需要授权
先登陆
#/usr/bin/mysql -uroot -p
再授权
#grant all on *.* to root@‘%‘ identified by ‘123456‘;
#flush privileges;
好了,至此,mysql基本上可以使用了。