Centos6.5使用yum安装mysql——快速上手必备

转载:http://blog.csdn.net/xxd851116/article/details/22947891
 

关掉SELINUX:vi /etc/selinux/config ,设置SELINUX=disabled,保存退出。

关闭防火墙:/sbin/service iptables stop;chkconfig --level 35 iptables off

参考:http://www.cnblogs.com/brucebi/p/3166851.html

第1步、yum安装mysql
[root@stonex ~]#  yum -y install mysql-server
安装结果:
Installed:
    mysql-server.x86_64 0:5.1.73-3.el6_5                                                                                                                                                         
Dependency Installed:
    mysql.x86_64 0:5.1.73-3.el6_5                                perl-DBD-MySQL.x86_64 0:4.013-3.el6                                perl-DBI.x86_64 0:1.609-4.el6

第2步、设置开机启动
[root@stonex ~]#  chkconfig mysqld on

第3步、启动MySql服务
[root@stonex ~]#  service mysqld start

第4步、设置MySQL的root用户设置密码
[root@stonex ~]#  mysql -u root
Welcome to the MySQL monitor.  Commands end with ; or g.
...... 省略了一些行
mysql> select user,host,password from mysql.user;
查询用户的密码,都为空,用下面的命令设置root的密码为root
mysql> set password for root@localhost=password('root');
mysql> exit

第5步、用新密码登陆
[root@stonex ~]#  mysql -u root -p

第6步、基本命令
show databases; //查看系统已存在的数据库
use databasesname;   //选择需要使用的数据库
drop database databasename; //删除选定的数据库
exit    //退出数据库的连接
create database test01;    //建立名为test的数据库
show tables;        // 列出当前数据库下的表
其他基本的增删改查使用标准SQL即可
 
第7步、开放远程登录权限
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'root' WITH GRANT OPTION;
FLUSH PRIVILEGES;
 
 

CentOS6.5系统下RPM包安装MySQL5.6

http://www.linuxidc.com/Linux/2015-04/116003.htm

在CentOS系统中防火墙默认是阻止3306端口的,我们要是想访问mysql数据库,我们需要这个端口,命令如下:
/sbin/iptables -I INPUT -p tcp --dport 3306 -j ACCEPT
我们需要保存我们的操作,命令如下:
/etc/rc.d/init.d/iptables save
此时我们可以查看端口的状态,命令如下:
/etc/init.d/iptables status
当然如果你打开其他端口也一样,只需要把这个端口号换乘你需要的端口号即可。

修改编码为utf8

/etc/my.cnf
character-set-server=utf8

原文地址:https://www.cnblogs.com/hclabxing/p/5814276.html