Red Hat Linux环境下的MYSQL配置

Red Hat Linux环境下的MYSQL配置

MySQL是一个关系型数据库管理系统,由瑞典MySQL AB 公司开发,目前属于 Oracle 旗下产品。MySQL 是最流行的关系型数据库管理系统之一,在 WEB 应用方面,MySQL是最好的 RDBMS (Relational Database Management System,关系数据库管理系统) 应用软件之一。

一. 配置 YUM 仓库

在各主机中,指定 YUM 仓库至 FTP,编写 YUM 配置文件。

1.删除原有的源文件

#rm -rf /etc/yum.repos.d/*

2.打开 /etc/yum.repos.d/server.repo,并输入以下内容

#vim /etc/yum.repos.d/server.repo
[server]
name=server
baseurl=file:///media
gpgcheck=0
# vim /etc/rc.local
umount /dev/cdrom
mount /dev/cdrom /media/

3. 清空 YUM 缓存

#yum clean all

4. 重新挂载

#umount /dev/sr0
#mount /dev/sr0 /media

5. 验证 YUM 仓库

#yum list

#yum groupinstall “Development tools”
#yum install lib* ncurses*

二. 防火墙与 SELinux 配置

#vim /etc/sysconfig/selinux
SELINUX=disabled
#iptables -F
#service iptables save

三.MySQL 部署

1.解压 MySQL 软件包: (先将软件包拖到虚拟机中)

点我下载软件包
#tar -zxvf mysql-5.1.44.tar.gz -C /usr/src/

2.添加相关用户并安装软件:

#useradd -M -s /sbin/nologin mysql
#cd /usr/src/mysql-5.1.44/
#./configure --prefix=/usr/local/mysql --with-mysqld-user=mysql
Thank you for choosing MySQL!
Remember to check the platform specific part of the reference
manual
for hints about installing MySQL on your platform.
Also have a look at the files in the Docs directory.
#make
#make install

3.复制主配置文件:

#cp support-files/my-medium.cnf /etc/my.cnf

4.数据库初始化:

#/usr/local/mysql/bin/mysql_install_db --user=mysql

5.修改相关目录所有权:

#chown -R root:mysql /usr/local/mysql
#chown -R mysql /usr/local/mysql/var

6.添加动态链接库配置:

#echo “/usr/local/mysql/lib/mysql” >> /etc/ld.so.conf
#ldconfig

7.启动数据库并查看状态:

#/usr/local/mysql/bin/mysqld_safe --user=mysql &
#cp support-files/mysql.server /etc/init.d/mysqld
#chmod +x /etc/init.d/mysqld
#chkconfig --add mysqld
#chkconfig mysqld on

8.修改环境变量:

#vim /etc/profile
export PATH=$PATH:/usr/local/mysql/bin/
#source /etc/profile

9.修改管理员密码并登陆至 SQL 界面操作验证:

#mysqladmin -u root password redhat
#mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 21
Server version: 5.1.44-log Source distribution
Type ‘help;’ or ‘\h’ for help. Type ‘\c’ to clear the current
input statement.
mysql> SHOW DATABASES;
±-----------------------+
| Database |
±-----------------------+
| information_schema |
| mysql |
| test |
±-----------------------+
4 rows in set (0.12 sec)
mysql> EXIT

10.建立数据库

#mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 83
Server version: 5.1.44-log Source distribution
Type ‘help;’ or ‘\h’ for help. Type ‘\c’ to clear the current
input statement.
mysql> CREATE DATABASE bbs;
Query OK, 1 row affected (0.00 sec)
mysql> EXIT
Bye

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值