yum在线安装mysql服务

1. 安装MySQL服务

 

#查询是否安装mysql-server,示例中并未安装
rpm -qa | grep mysql

mysql-devel-5.1.52-1.el6_0.1.x86_64
mysql-5.1.52-1.el6_0.1.x86_64
mysql-libs-5.1.52-1.el6_0.1.x86_64

#使用 yum -y install mysql-server安装
yum -y install mysql-server

#设置mysql-server开机自启动
chkconfig mysqld on

#可检查是否设置成功(2、3、4、5项为on即设置正常)
chkconfig --list | grep mysqld
mysqld             0:off    1:off    2:on    3:on    4:on    5:on    6:off

 

 

2. 启动MySQL服务

 

#以服务名方式启动
service mysqld start  
#从文件启动MySql服务         
c.d/init.d/mysqld start

 

 

3. 配置MySQL

 

#默认root密码为空
mysql -u root

#可查询用户信息 select user,host,password from mysql.user;

mysql> select user,host,password from mysql.user;
+------+------------+----------+
| user | host       | password |
+------+------------+----------+
| root | localhost  |          |
| root | crxj-app-1 |          |
| root | 127.0.0.1  |          |
|      | localhost  |          |
|      | crxj-app-1 |          |
+------+------------+----------+
5 rows in set (0.00 sec)

#设置root用户密码
SET PASSWORD FOR 'root'@'localhost' = PASSWORD('yourRootPwd');

#使用exit退出,使用新密码登录
exit
mysql -uroot -p

#可以查看默认包含的数据库
mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| test               |
+--------------------+
3 rows in set (0.00 sec)

 

 

至此完成所有MySQL安装配置工作

 

 

 

转载请标明作者和原文链接

ifuteng#gmail.com  2014/6/23 16:24

 

猜你喜欢

转载自futeng.iteye.com/blog/2084035