centOS 安装mysql

yum list mysql-server

当只有一个时候就可以直接
yum install mysql-server

先启动Mysql服务
service mysqld start

连接一下试一下,直接
mysql

然后
\q
关闭连接

设置Mysql开机启动
chkconfig mysqld on

开启3306端口并保存
/sbin/iptables -I INPUT -p tcp --dport 3306 -j ACCEPT
/etc/rc.d/init.d/iptables save

连接mysql数据库
use mysql;
设置密码
update user set password=password('itliucheng') where user='root';
flush privileges;

设置Mysql远程访问
grant all privileges on *.* to 'root'@'%' identified by 'itliucheng' with grant option;

解决Mysql乱码问题
找一个配置文件,复制到/etc/目录,命名为my.cnf
(有时候没有my.cnf)
cp /usr/share/doc/mysql-server-5.1.73/my-medium.cnf /etc/my.cnf

vim my.cnf
在[client]和[mysqld]下面都添加上
default-character-set=utf8
最后按Esc输入
:wq
保存退出
最后重新启动服务就可以了
service mysqld restart

posted on 2015-12-24 14:06  itliucheng  阅读(165)  评论(0编辑  收藏  举报