安装Mysql
- 查看mysql-server包列表 - 1 - yum list mysql-server 
- 选择对应版本安装 - 1 - yum install mysql-server.x86_64 
设置Mysql的服务
- 启动Mysql服务 - 1 - service mysqld start 
- 设置mysql开机自启 - 1 - chkconfig mysqld on 
- 开启3306端口并保存 - 1 
 2- /sbin/iptables -I INPUT -p tcp --dport 3306 -j ACCEPT 
 /etc/rc.d/init.d/iptables save
修改密码并设置远程访问
- 连接mysql数据库 - 1 - mysql -uroot -p 
- 设置密码 - 1 
 2
 3
 4
 5
 6
 7
 8- # 选择mysql数据库 
 use mysql;
 # 将root用户的密码设置为root
 update user set password=password('root') where user='root';
 # 强制让MySQL重新加载权限,使修改马上生效
 flush privileges;
- 设置Mysql远程访问。配置远程登陆时,需要的用户名(root)和密码(123456) - 1 - grant all privileges on *.* to 'root'@'%' identified by '123456' with grant option; 
解决Mysql乱码问题
- 找到配置文件,复制到/etc/目录,命名为my.cnf - 1 - cp /usr/share/doc/mysql-server-5.1.73/my-medium.cnf /etc/my.cnf 
- 在[client]和[mysqld]下面都添加上“default-character-set=utf8” - 1 - vim my.cnf 
- 最后重新启动服务就可以了 - 1 - service mysqld restart 
