您的位置:首页 > 运维架构 > Linux

CentOS6下安装MySQL数据库服务

2015-08-03 23:19 579 查看
大家好,今天是我在51CTO上的第一篇博文,以此来督促我自个养成一个好的学习习惯,也希望给大家有所帮助。
ok,言归正传,今天我介绍的是在CentOS6环境下安装MySQL数据库,我所用到的是CentOS6镜像文件中所带的mysql包。
1、配置本地yum源。
[root@server ~]# cd /etc/yum.repos.d/
[root@server yum.repos.d]# ls
CentOS-Base.repo.bak CentOS-Debuginfo.repo.bak CentOS-fasttrack.repo.bak CentOS-Media.repo CentOS-Vault.repo.bak
修改如下:
[root@server yum.repos.d]# vim CentOS-Media.repo
baseurl=file:///mnt */mnt为挂载点*
enabled=1 *开启状态*
2、安装mysql。
[root@server ~]# yum list | grep mysql *查询与mysql有关的包*
[root@server ~]# yum install -y mysql-server.x86_64 mysql.x86_64 mysql-devel.x86_64 *安装mysql包和开发所用到的包*
[root@server ~]# service mysqld start *初始化mysql数据库*
[root@server ~]# service mysqld restart *重启mysql服务*
[root@server ~]# mysqladmin -u root password '123456' *配置管理mysql的用户的密码*
[root@server ~]# mysql -u root -p
Enter password: *登录mysql,输入管理密码*
出现如下,表示登录成功:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 12
Server version: 5.1.73 Source distribution

Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql>
相关命令: show databases; *查看目前有的数据库*
create database ming; *创建名字为ming的数据库*
3、mysql的配置文件。
[root@server ~]# cd /etc/
[root@server etc]# ls my.cnf
my.cnf
4、mysql数据库的库所在位置。
[root@server ~]# cd /var/lib/mysql/
[root@server mysql]# ls
ibdata1 ib_logfile0 ib_logfile1 ming mingming mysql mysql.sock test
5、mysql数据库的日志文件所在位置。
[root@server ~]# cd /var/log/
[root@server log]# ls
anaconda.ifcfg.log btmp dmesg maillog-20150802 prelink spooler-20150714
anaconda.log btmp-20150802 dmesg.old mcelog sa spooler-20150719
anaconda.program.log ConsoleKit dracut.log messages samba spooler-20150730
anaconda.storage.log cron httpd messages-20150714 secure spooler-20150802
anaconda.syslog cron-20150714 lastlog messages-20150719 secure-20150714 sssd
anaconda.xlog cron-20150719 maillog messages-20150730 secure-20150719 tallylog
anaconda.yum.log cron-20150730 maillog-20150714 messages-20150802 secure-20150730 wtmp
audit cron-20150802 maillog-20150719 mysqld.log secure-20150802 yum.log
boot.log cups maillog-20150730 ntpstats spooler
[root@server log]# cat mysqld.log
Version: '5.1.73' socket: '/var/lib/mysql/mysql.sock' port: 3306 Source distribution
*mysql服务是TCP,端口号为3306*
6、监听mysql服务。
[root@server ~]# netstat -tlun
tcp 0 0 0.0.0.0:3306 0.0.0.0:* LISTEN

******此文结束*******
2015-8-3

本文出自 “努力!奋斗!” 博客,请务必保留此出处http://026mm.blog.51cto.com/8783374/1681434
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: