大家好,今天是我在51CTO上的第一篇博文,以此来督促我自个养成一个好的学习习惯,也希望给大家有所帮助。
ok,言归正传,今天我介绍的是在CentOS6环境下安装MySQL数据库,我所用到的是CentOS6镜像文件中所带的mysql包。
1、配置本地yum源。
[[email protected] ~]# cd /etc/yum.repos.d/
[[email protected] yum.repos.d]# ls
CentOS-Base.repo.bak CentOS-Debuginfo.repo.bak CentOS-fasttrack.repo.bak CentOS-Media.repo CentOS-Vault.repo.bak
修改如下:
[[email protected] yum.repos.d]# vim CentOS-Media.repo
baseurl=file:///mnt */mnt为挂载点*
enabled=1 *开启状态*
2、安装mysql。
[[email protected] ~]# yum list | grep mysql *查询与mysql有关的包*
[[email protected] ~]# yum install -y mysql-server.x86_64 mysql.x86_64 mysql-devel.x86_64 *安装mysql包和开发所用到的包*
[[email protected] ~]# service mysqld start *初始化mysql数据库*
[[email protected] ~]# service mysqld restart *重启mysql服务*
[[email protected] ~]# mysqladmin -u root password ‘123456‘ *配置管理mysql的用户的密码*
[[email protected] ~]# 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的配置文件。
[[email protected] ~]# cd /etc/
[[email protected] etc]# ls my.cnf
my.cnf
4、mysql数据库的库所在位置。
[[email protected] ~]# cd /var/lib/mysql/
[[email protected] mysql]# ls
ibdata1 ib_logfile0 ib_logfile1 ming mingming mysql mysql.sock test
5、mysql数据库的日志文件所在位置。
[[email protected] ~]# cd /var/log/
[[email protected] 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
[[email protected] log]# cat mysqld.log
Version: ‘5.1.73‘ socket: ‘/var/lib/mysql/mysql.sock‘ port: 3306 Source distribution
*mysql服务是TCP,端口号为3306*
6、监听mysql服务。
[[email protected] ~]# netstat -tlun
tcp 0 0 0.0.0.0:3306 0.0.0.0:* LISTEN
******此文结束*******
2015-8-3