LInux上MySQL的安装

本篇参考博客

Linux学习之CentOS(十三)--CentOS6.4下Mysql数据库的安装与配置

1.myspl简介

当在linux上进行开发的时候,无论再小的一个项目都需要数据库。MySQL是一个关系型数据库管理系统,由瑞典MySQL AB公司开发,目前属于Oracle公司。MySQL是一种关联数据库管理系统,关联数据库将数据保存在不同的表中,而不是将所有数据放在一个大仓库内,这样就增加了速度并提高了灵活性。MySQL的SQL语言是用于访问数据库的最常用标准化语言。

2.安装过程

1.首先通过rpm -qa | grep mysql命令查看是否安装了mySQL数据库。

(如果有的话可以通过rmp -e mysql 为普通删除命令。另外还有rpm -e --nodeps mysql命令来强力卸载掉mysql。

2.通过yum来进行mysql的安装。首先可以查看可以安装的版本

3.通过输入 yum install -y mysql-server mysql mysql-devel 命令将mysql mysql-server mysql-devel都安装好(注意:安装mysql时我们并不是安装了mysql客户端就相当于安装好了mysql数据库了,我们还需要安装mysql-server服务端才行)

4启动mysql 通过输入service mysqld start 就可以开启服务。如果是第一次启动mysql服务,mysql服务器会首先进行初始化。

[root@xiaoluo ~]# service mysqld start
初始化 MySQL 数据库: WARNING: The host 'xiaoluo' could not be looked up with resolveip.
This probably means that your libc libraries are not 100 % compatible
with this binary MySQL version. The MySQL daemon, mysqld, should work
normally with the exception that host name resolving will not work.
This means that you should use IP addresses instead of hostnames
when specifying MySQL privileges !
Installing MySQL system tables...
OK
Filling help tables...
OK

To start mysqld at boot time you have to copy
support-files/mysql.server to the right place for your system

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 xiaoluo 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.

You can start the MySQL daemon with:
cd /usr ; /usr/bin/mysqld_safe &

You can test the MySQL daemon with mysql-test-run.pl
cd /usr/mysql-test ; perl mysql-test-run.pl

Please report any problems with the /usr/bin/mysqlbug script![确定]
正在启动 mysqld:                                            [确定]

当再次启动mysql时就会有这么多初始化了

启动mysql之前要先启动mysqld服务,可以通过chkconfig --list | grep mysqld 命令来查看mysql服务是不是开机自动启动。

我们可以看出,mysql服务并没有开机便启动,因此我们可以通过chkconfig mysqld on 设置其开机自启动

mysql数据库安装完以后只会有一个root管理员账号,但是此时的root账号还并没有为其设置密码,在第一次启动mysql服务时,会进行数据库的一些初始化工作,在输出的一大串信息中,我们看到有这样一行信息 :

所以我们可以通过 该命令来给我们的root账号设置密码(注意:这个root账号是mysql的root账号,非Linux的root账号)

此时我们就可以通过 mysql -u root -p 命令来登录我们的mysql数据库了

猜你喜欢

转载自blog.csdn.net/qq_39161003/article/details/84168683