Linux下Mysql安装

1、下载安装包

     首先查看Linux版本:

[root@localhost ~]# lsb_release -a
LSB Version:    :core-4.0-amd64:core-4.0-noarch:graphics-4.0-amd64:graphics-4.0-noarch:printing-4.0-amd64:printing-4.0-noarch
Distributor ID:    RedHatEnterpriseServer
Description:    Red Hat Enterprise Linux Server release 6.3 (Santiago)
Release:    6.3
Codename:    Santiago

  结果显示系统为64位Redhat6.3 ,去Mysql官网(http://dev.mysql.com/downloads/mysql#downloads)下载相应的版本。

wget http://cdn.mysql.com/Downloads/MySQL-5.5/MySQL-devel-5.5.36-1.el6.x86_64.rpm
wget http://cdn.mysql.com/Downloads/MySQL-5.5/MySQL-client-5.5.36-1.el6.x86_64.rpm
wget http://cdn.mysql.com/Downloads/MySQL-5.5/MySQL-server-5.5.36-1.el6.x86_64.rpm

2、安装Mysql服务和客户端

rpm -ivh MySQL-server-5.5.36-1.el6.x86_64.rpm
[root@localhost mysql]# rpm -ivh MySQL-server-5.5.36-1.el6.x86_64.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 at http://bugs.mysql.com/

[root@localhost mysql]# rpm -ivh MySQL-client-5.5.36-1.el6.x86_64.rpm
Preparing... ########################################### [100%]
1:MySQL-client ########################################### [100%]

可能遇到的问题

1>如果出现类似:

file /usr/share/mysql/charsets/hebrew.xml from install of MySQL-server-5.5.36-1.el6.x86_64 conflicts with file from package mysql-libs-5.1.61-4.el6.x86_64
    file /usr/share/mysql/charsets/hp8.xml from install of MySQL-server-5.5.36-1.el6.x86_64 conflicts with file from package mysql-libs-5.1.61-4.el6.x86_64
    file /usr/share/mysql/charsets/keybcs2.xml from install of MySQL-server-5.5.36-1.el6.x86_64 conflicts with file from package mysql-libs-5.1.61-4.el6.x86_64
    file /usr/share/mysql/charsets/koi8r.xml from install of MySQL-server-5.5.36-1.el6.x86_64 conflicts with file from package mysql-libs-5.1.61-4.el6.x86_64
    file /usr/share/mysql/charsets/koi8u.xml from install of MySQL-server-5.5.36-1.el6.x86_64 conflicts with file from package mysql-libs-5.1.61-4.el6.x86_64
    file /usr/share/mysql/charsets/latin1.xml from install of MySQL-server-5.5.36-1.el6.x86_64 conflicts with file from package mysql-libs-5.1.61-4.el6.x86_64

说明有包冲突,这时候要移除冲突的包,使用命令:

yum -y remove mysql-libs-5.1.61*

2>如果移除时出现:

Loaded plugins: product-id, refresh-packagekit, security, subscription-manager
Updating certificate-based repositories.
Unable to read consumer identity
Existing lock /var/run/yum.pid: another copy is running as pid 14110.

说明YUM正在更新,使用命令:

rm -f    /var/run/yum.pid

3、服务启动、停止、重新启动

[root@localhost usr]# service mysql start

[root@localhost usr]# service mysql stop

[root@localhost usr]# service mysql restart

4、修改root密码

[root@localhost bin]# mysqladmin -u root -p‘root‘ password ‘rockontrol‘

Linux下Mysql安装,古老的榕树,5-wow.com

郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。