首先我们通过命令yum list | grep mysql看看MySQL是否被安装过
[root@linuxidc.com /]# yum list | grep mysql
然后通过yum的方式来进行mysql的数据库安装,首先我们可以输入 yum list | grep mysql 命令来查看。
yum上提供的mysql数据库可下载的版本信息
mysql-libs.x86_64 5.1.73-7.el6 @base apr-util-mysql.x86_64 1.3.9-3.el6_0.1 base bacula-director-mysql.x86_64 5.0.0-13.el6 base bacula-storage-mysql.x86_64 5.0.0-13.el6 base dovecot-mysql.x86_64 1:2.0.9-22.el6 base freeradius-mysql.x86_64 2.2.6-6.el6_7 base libdbi-dbd-mysql.x86_64 0.8.3-5.1.el6 base mod_auth_mysql.x86_64 1:3.0.0-11.el6_0.1 base mysql.x86_64 5.1.73-8.el6_8 base mysql-bench.x86_64 5.1.73-8.el6_8 base mysql-connector-Java.noarch 1:5.1.17-6.el6 base mysql-connector-odbc.x86_64 5.1.5r1144-7.el6 base mysql-devel.i686 5.1.73-8.el6_8 base mysql-devel.x86_64 5.1.73-8.el6_8 base mysql-embedded.i686 5.1.73-8.el6_8 base mysql-embedded.x86_64 5.1.73-8.el6_8 base mysql-embedded-devel.i686 5.1.73-8.el6_8 base mysql-embedded-devel.x86_64 5.1.73-8.el6_8 base mysql-libs.i686 5.1.73-8.el6_8 base mysql-libs.x86_64 5.1.73-8.el6_8 base mysql-server.x86_64 5.1.73-8.el6_8 base mysql-test.x86_64 5.1.73-8.el6_8 base pcp-pmda-mysql.x86_64 3.10.9-9.el6 base php-mysql.x86_64 5.3.3-49.el6 base qt-mysql.i686 1:4.6.2-28.el6_5 base qt-mysql.x86_64 1:4.6.2-28.el6_5 base rsyslog-mysql.x86_64 5.8.10-10.el6_6 base rsyslog7-mysql.x86_64 7.4.10-7.el6 base
并且通过yum install -y mysql-server mysql mysql-devel命令进行安装
[root@linuxidc.com /]# yum list | grep mysql [root@linuxidc.com /]# yum install -y mysql-server mysql mysql-devel
安装成功后可以通过rpm -qi mysql-server命令查看安装后MySQL的信息,可以通过service mysqld start 启动服务
[root@linuxidc.com /]# rpm -qi mysql-server
Name : mysql-server Relocations: (not relocatable)
Version :5.1.73 Vendor: CentOS
Release :8.el6_8 Build Date: Fri 27 Jan 2017 06:25:43 AM CST
Install Date: Mon08 May 2017 09:32:41 AM CST Build Host: c1bm.rdu2.centos.org
Group : Applications/Databases Source RPM: mysql-5.1.73-8.el6_8.src.rpm
Size :25884131 License: GPLv2 with exceptions Signature : RSA/SHA1, Fri 27 Jan 2017 06:35:28 AM CST, Key ID 0946fca2c105b9de
Packager : CentOS BuildSystem<http://bugs.centos.org>
URL : http://
Summary : The MySQL server and related files
Description :
MySQL is a multi-user, multi-threaded SQL database server. MySQL is a
client/server implementation consisting of a server daemon (mysqld)
and many different client programs and libraries. Thispackage contains
the MySQL server and some accompanying files and directories.
MySQL主要文件位置:
/var/lib/mysql mysql数据库的数据库文件存放位置
/var/log mysql数据库的日志输出存放位置
/etc/my.cnf 这是mysql的主配置文件
接下来系统还会提示你去设置root的密码
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 linuxidc.com.novalocal password 'new-password'
Alternatively you can run:
/usr/bin/mysql_secure_installation
我这里敲入的是
[root@linuxidc.com /] /usr/bin/mysqladmin -u root password '123456'
设置好root的密码后,可以通过mysql -u root -p,然后输入密码进行对MySQL访问了。另外我们可以 通过 chkconfig --list | grep mysqld 命令来查看mysql服务是不是开机自动启动,并且通过chkconfig mysqld on 命令来将其设置成开机启动
配置MySQL远程访问
在CentOS上搭建MySQL过程后,默认的root账户只能在本机访问的,如果想通过其他机器访问CentOS上的MySQL数据库,需要进行一番配置方可进行访问。
敲入下面命令意思就是dba用户允许访问,%是匹配所有的域名,密码是rootpasswd