第一步:[root@wuhan ~]# yum list | grep mysql   查看mysql数据库的包信息

第二步:[root@wuhan ~]# yum -y install mysql-server mysql mysql-devel 安装mysql数据包

第三步:[root@wuhan ~]# rpm -qi mysql-server查看mysql软件的详细信息

第四步:[root@wuhan ~]# service mysqld restart初始化mysql服务

第五步:重新启动mysql服务,设置为开机启动
                [root@wuhan ~]# service mysqld restart
                停止 mysqld: [确定]
                正在启动 mysqld: [确定]
                [root@wuhan ~]# chkconfig --list | grep mysqld
                mysqld          0:关闭  1:关闭  2:关闭  3:关闭  4:关闭  5:关闭  6:关闭
                [root@wuhan ~]# chkconfig mysqld on
                [root@wuhan ~]# chkconfig --list | grep mysqld
                mysqld          0:关闭  1:关闭  2:启用  3:启用  4:启用  5:启用  6:关闭
                [root@wuhan ~]# 
                [root@wuhan ~]# netstat -tunlp | grep mysqld
                tcp        0      0 0.0.0.0:3306                0.0.0.0:*                   LISTEN      3092/mysqld      

第六步:初始化mysql密码
                [root@wuhan ~]# mysqladmin -u root password '123456'

第七步:登录mysql数据库
               [root@wuhan ~]# mysql -u root -p          -p检测用户的密码
               Enter password:
               Welcome to the MySQL monitor.  Commands end with ; or \g.
               Your MySQL connection id is 4
               Server version: 5.1.73 Source distribution

第八步:查看mysql的配置文件
[root@wuhan ~]# cd /etc/
[root@wuhan etc]# ls my.cnf
my.cnf
[root@wuhan etc]# cat my.cnf
[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
user=mysql
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0

[mysqld_safe]
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
[root@wuhan etc]#


第九步:mysql数据库文件存放的位置
[root@wuhan ~]# cd /var/lib/mysql/
[root@wuhan mysql]# pwd
/var/lib/mysql
[root@wuhan mysql]# ls
ibdata1  ib_logfile0  ib_logfile1  mysql  mysql.sock  test
[root@wuhan mysql]#


第十步:mysql日志文件存放的位置
Bye
[root@wuhan ~]# cd /var/log/
mysqld.log


第十一步:连接远程mysql数据库的
[root@wuhan ~]# mysql -h 192.168.0.167(shanghai.cpipec.com) -u root -p


第十二步:连接本地的mysql数据库
[root@wuhan ~]# mysql -h localhost -u root -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 10
Server version: 5.1.73 Source distribution

第十三步:查看mysql数据库的版本
mysql> select version();
+-----------+
| version() |
+-----------+
| 5.1.73    |
+-----------+
1 row in set (0.00 sec)

第十四步:查看系统默认的数据库
mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| test               |
| yinhe              |
+--------------------+
4 rows in set (0.00 sec)

第十五步:查看当前的时间
mysql> select current_date;
+--------------+
| current_date |
+--------------+
| 2015-04-02   |
+--------------+
1 row in set (0.00 sec)

 操作完成,如有问题请及时跟我联系!