一、安装
1、yum进行mysql的安装
首先输入 yum list | grep mysql 命令来查看yum上提供的mysql数据库可下载的版本:
[root@xiaoluo ~]# yum list | grep mysql
就可以得到yum服务器上mysql数据库的可下载版本信息:
然后通过输入 yum install -y mysql-server mysql mysql-devel 命令将mysql mysql-server mysql-devel都安装好
(注意:安装mysql时并不是安装了mysql客户端就相当于安装好了mysql数据库了,还需要安装mysql-server服务端才行)
[root@xiaoluo ~]# yum install -y mysql-server mysql mysql-devel
1.2 mysql数据库的初始化及相关配置
在安装完mysql数据库以后,会发现会多出一个mysqld的服务,这个就是我们的数据库服务,可以通过输入 service mysqld start 命令就可以启动我们的mysql服务。
注意:如果我们是第一次启动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