@CentOS安装MySQL金沙官网线上

1.查看是否已经安装了mysql

在这里通过yum来进行MySQL数据库的安装,通过这种方式进行安装,可以将跟MySQL相关的一些服务、jar包都给我们安装好,所以省去了很多不必要的麻烦!!!

金沙官网线上 1

1.卸载掉原有MySQL

系统默认装了一个mysql-libs,我们卸载掉

目前主流Linux系统版本基本上都集成了MySQL数据库,我们可以通过如下命令来查看我们的操作系统上是否已经安装了MySQL数据库

 

// 这个命令就会查看该操作系统上是否已经安装了mysql数据库
[root@winner ~]# rpm -qa | grep mysql

[root@localhost winner_0715]# rpm -qa | grep mysql
mysql-libs-5.1.73-5.el6_6.x86_64

2.去下载mysql所必须的rpm包

有的话,我们就通过rpm -e命令或者rpm -e  --nodeps命令来卸载掉,在删除完以后我们可以通过rpm -qa | grep mysql命令来查看mysql是否已经卸载成功!!

 金沙官网线上 2

[root@localhost winner_0715]# rpm -e --nodeps mysql-libs-5.1.73-5.el6_6.x86_64
[root@localhost winner_0715]# rpm -qa | grep mysql
[root@localhost winner_0715]# find / -name mysql

 

至此,系统原有的mysql删除完毕。

金沙官网线上 3

2.在MySQL官网下载安装MySQL-5.6.21所需的rpm软件包。

注:红框里的这个mysql-community-devel 就不装了,貌似用处暂时用不到

需要下载三个rpm软件包:
MySQL-client-5.6.21-1.rhel5.x86_64.rpm  
MySQL-devel-5.6.21-1.rhel5.x86_64.rpm  
MySQL-server-5.6.21-1.rhel5.x86_64.rpm 

 

[root@localhost software]# wget http://dev.mysql.com/Downloads/MySQL-5.6/MySQL-server-5.6.21-1.rhel5.x86_64.rpm
[root@localhost software]# wget http://dev.mysql.com/Downloads/MySQL-5.6/MySQL-devel-5.6.21-1.rhel5.x86_64.rpm 
[root@localhost software]# wget http://dev.mysql.com/Downloads/MySQL-5.6/MySQL-client-5.6.21-1.rhel5.x86_64.rpm

 

3.下载完之后,安装三个rpm软件包

 

[root@localhost software]# rpm -ivh MySQL-server-5.6.21-1.rhel5.x86_64.rpm 

3.进行rpm软件包安装

error: Failed dependencies:
        libaio.so.1()(64bit) is needed by MySQL-server-5.6.21-1.rhel5.x86_64
        libaio.so.1(LIBAIO_0.1)(64bit) is needed by MySQL-server-5.6.21-1.rhel5.x86_64
        libaio.so.1(LIBAIO_0.4)(64bit) is needed by MySQL-server-5.6.21-1.rhel5.x86_64
安装MySQL-server报错,原因是没有安装libaio,系统缺少libaio.so此软件包,下边yum安装一下libaio.so软件包。

 

[root@localhost software]#yum install -y libaio 

[root@localhost software]# rpm -ivh MySQL-server-5.6.21-1.rhel5.x86_64.rpm 

[root@localhost software]# rpm -ivh MySQL-client-5.6.21-1.rhel5.x86_64.rpm  

[root@localhost software]# rpm -ivh MMySQL-devel-5.6.21-1.rhel5.x86_64.rpm  

金沙官网线上 4

注意,在安装server的时候一定要仔细看一下安装的详细信息,因为默认的初始密码会包含在其中,有的版本默认是没有密码的,我安装的这个则是有密码的~

金沙官网线上 5

A RANDOM PASSWORD HAS BEEN SET FOR THE MySQL root USER !
You will find that password in '/root/.mysql_secret'.

You must change that password on your first connect,
no other statement but 'SET PASSWORD' will be accepted.
See the manual for the semantics of the 'password expired' flag.

Also, the account for the anonymous user has been removed.

In addition, you can run:

  /usr/bin/mysql_secure_installation

which will also give you the option of removing the test database.
This is strongly recommended for production servers.

See the manual for more instructions.

Please report any problems at http://bugs.mysql.com/

The latest information about MySQL is available on the web at

  http://www.mysql.com

Support MySQL by buying support/licenses at http://shop.mysql.com

New default config file was created as /usr/my.cnf and
will be used by default by the server when you start it.
You may edit this file to change server settings

 

怎么看mysql是不是安装成功了呢?

 

可以通过查看mysql安装时创建的mysql用户和mysql组

 

[root@localhost software]# cat /etc/passwd|grep mysql
mysql:x:27:27:MySQL Server:/var/lib/mysql:/bin/bash
[root@localhost software]# cat /etc/group|grep mysql
mysql:x:27:

4.初始化数据库,开启数据库

或者可以执行mysqladmin --version,打印出消息即成功~

金沙官网线上 6

[root@localhost software]# mysqladmin --version
mysqladmin  Ver 8.42 Distrib 5.6.21, for Linux on x86_64

 

4.mysql服务的启动与停止

5.设置数据库密码

#service mysql start

#service mysql stop

#service mysql restart

[root@localhost software]# ps -ef|grep mysql
root       3327   2615  0 22:51 pts/0    00:00:00 grep mysql
[root@localhost software]# service mysql start
Starting MySQL...                                          [  OK  ]
[root@localhost software]# ps -ef|grep mysql
root       3340      1  0 22:51 pts/0    00:00:00 /bin/sh /usr/bin/mysqld_safe --datadir=/var/lib/mysql --pid-file=/var/lib/mysql/localhost.localdomain.pid
mysql      3443   3340  4 22:51 pts/0    00:00:00 /usr/sbin/mysqld --basedir=/usr --datadir=/var/lib/mysql --plugin-dir=/usr/lib64/mysql/plugin --user=mysql --log-error=/var/lib/mysql/localhost.localdomain.err --pid-file=/var/lib/mysql/localhost.localdomain.pid
root       3479   2615  0 22:51 pts/0    00:00:00 grep mysql

[root@localhost software]# service mysql stop
Shutting down MySQL..                                      [  OK  ]
[root@localhost software]# ps -ef|grep mysql
root       3516   2615  0 22:54 pts/0    00:00:00 grep mysql

金沙官网线上 7

 5.修改密码

默认的是有密码的,密码既不是空,也不是'root‘

使用默认的初始密码登录之后必须修改密码才能执行后续操作

本文由金沙官网线上发布于数据库,转载请注明出处:@CentOS安装MySQL金沙官网线上

您可能还会对下面的文章感兴趣: