centos6.5yum安装mysql
一、查看系统中是否安装了mysql
[root@pc ~]# rpm -qa | grep mysql
mysql-devel-5.1.73-7.el6.x86_64
mysql-server-5.1.73-7.el6.x86_64
mysql-libs-5.1.73-7.el6.x86_64
mysql-5.1.73-7.el6.x86_64
二、卸载原来的mysql
rpm -e --nodeps mysql
三、安装mysql
1.查看yum服务器中与mysql有关的软件
yum list | grep mysql
2.下载、安装
yum install -y mysql-server mysql mysql-devel
最后显示:
Installed:
mysql.x86_64 0:5.1.73-7.el6
Complete!
四、常用操作
1.启动服务:service mysqld start
2.设置root账号的密码:/usr/bin/mysqladmin -u root password 你的密码
3.登录mysql:mysql -u root -p
五、配置文件
1.主配置文件: vi /etc/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
2.数据文件存放目录:ll /var/lib/mysql
[root@pc ~]# ll /var/lib/mysql
total 20488
-rw-rw----. 1 mysql mysql 10485760 Dec 18 11:43 ibdata1
-rw-rw----. 1 mysql mysql 5242880 Dec 18 11:43 ib_logfile0
-rw-rw----. 1 mysql mysql 5242880 Dec 18 11:43 ib_logfile1
drwx------. 2 mysql mysql 4096 Dec 18 11:43 mysql
srwxrwxrwx. 1 mysql mysql 0 Dec 18 11:43 mysql.sock
drwx------. 2 mysql mysql 4096 Dec 18 11:43 test
3.日志目录: ll /var/log | grep mysql
-rw-r-----. 1 mysql mysql 1279 Dec 18 11:43 mysqld.log
六、允许root账号远程登录
mysql> grant all privileges on *.* to root@"%" identified by "root";
Query OK, 0 rows affected (0.00 sec)
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)