centos6.5下安装mysql
http://www.centoscn.com/mysql/2014/0812/3481.html
- [root@bogon ~]# yum -y install mysql-server
2.设置开机启动
- [root@bogon ~]# chkconfig mysqld on
3.启动MySQL服务
- [root@bogon ~]# service mysqld start
4.设置MySQL的root用户设置密码
- [root@bogon ~]# mysql -u root
- mysql> select user,host,password from mysql.user;
- +------+-----------+----------+
- | user | host | password |
- +------+-----------+----------+
- | root | localhost | |
- | root | bogon | |
- | root | 127.0.0.1 | |
- | | localhost | |
- | | bogon | |
- +------+-----------+----------+
- 5 rows in set (0.01 sec)
查询用户的密码,都为空,用下面的命令设置root的密码为root
- mysql> set password for root@localhost=password('root');
- mysql> exit
5.用新密码登陆
- [root@bogon ~]# mysql -u root -p
- Enter password:
6.创建mysql新用户test_user
- mysql> create user 'test_user'@'%' identified by 'test_user';
- Query OK, 0 rows affected (0.00 sec)
7.给新用户test_user授权,让他可以从外部登陆和本地登陆
注意:@左边是用户名,右边是域名、IP和%,表示可以访问mysql的域名和IP,%表示外部任何地址都能访问。
- mysql> grant all privileges on *.* to 'test_user'@'localhost' identified by 'test_user';
- Query OK, 0 rows affected (0.00 sec)
- mysql> grant all privileges on *.* to 'test_user'@'%' identified by 'test_user';
- Query OK, 0 rows affected (0.00 sec)
- mysql> select user,host,password from mysql.user;
- +----------+-----------+-------------------------------------------+
- | user | host | password |
- +----------+-----------+-------------------------------------------+
- | root | localhost | *81F5E21E35407D884A6CD4A731AEBFB6AF209E1B |
- | root | bogon | |
- | root | 127.0.0.1 | |
- | | localhost | |
- | | bogon | |
- | test_user | % | *3046CF87132BBD4FDDF06F321C6859074843B7D3 |
- | test_user | localhost | *3046CF87132BBD4FDDF06F321C6859074843B7D3 |
- +----------+-----------+-------------------------------------------+
- 7 rows in set (0.00 sec)
- mysql> flush privileges;
- Query OK, 0 rows affected (0.01 sec)
8.查看mysql5.1的默认存储引擎
从下面的执行结果可以看出,mysql的默认引擎是MyISAM,这个引擎是不支持事务的。
- mysql> show engines;
- +------------+---------+------------------------------------------------------------+--------------+------+------------+
- | Engine | Support | Comment | Transactions | XA | Savepoints |
- +------------+---------+------------------------------------------------------------+--------------+------+------------+
- | MRG_MYISAM | YES | Collection of identical MyISAM tables | NO | NO | NO |
- | CSV | YES | CSV storage engine | NO | NO | NO |
- | MyISAM | DEFAULT | Default engine as of MySQL 3.23 with great performance | NO | NO | NO |
- | InnoDB | YES | Supports transactions, row-level locking, and foreign keys | YES | YES | YES |
- | MEMORY | YES | Hash based, stored in memory, useful for temporary tables | NO | NO | NO |
- +------------+---------+------------------------------------------------------------+--------------+------+------------+
- 5 rows in set (0.00 sec)
也可以以下面的方式查看
- mysql> show variables like 'storage_engine';
- +----------------+--------+
- | Variable_name | Value |
- +----------------+--------+
- | storage_engine | MyISAM |
- +----------------+--------+
- 1 row in set (0.00 sec)
9.修改mysql的默认引擎为InnoDB
9.1 停止mysql
- mysql> exit;
- [root@bogon ~]# service mysqld stop
9.2 修改/etc/my.cnf
[mysqld] 后加入
- default-storage-engine=InnoDB
加入后my.cnf的内容为:
- [root@bogon etc]# more 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
- default-storage-engine=InnoDB
- [mysqld_safe]
- log-error=/var/log/mysqld.log
- pid-file=/var/run/mysqld/mysqld.pid
9.3 启动mysql
- [root@bogon etc]# service mysqld start
- Starting mysqld: [ OK ]
9.4 查看mysql默认存储引擎
- [root@bogon etc]# mysql -u root -p
- Enter password:
- Welcome to the MySQL monitor. Commands end with ; or \g.
- Your MySQL connection id is 2
- Server version: 5.1.73 Source distribution
- Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
- Oracle is a registered trademark of Oracle Corporation and/or its
- affiliates. Other names may be trademarks of their respective
- owners.
- Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
- mysql> show variables like 'storage_engine';
- +----------------+--------+
- | Variable_name | Value |
- +----------------+--------+
- | storage_engine | InnoDB |
- +----------------+--------+
- 1 row in set (0.00 sec)
10.CentOS6.5开放mysql端口3306
CentOS6.5默认是不开放端口的,如果要让外部的系统访问CentOS6.5上的mysql,必须开放mysql的端口3306
10.1 修改/etc/sysconfig/iptables
添加下面一行
- -A INPUT -m state --state NEW -m tcp -p tcp --dport 3306 -j ACCEPT
修改后iptables中的内容是
- [root@bogon etc]# more /etc/sysconfig/iptables
- # Firewall configuration written by system-config-firewall
- # Manual customization of this file is not recommended.
- *filter
- :INPUT ACCEPT [0:0]
- :FORWARD ACCEPT [0:0]
- :OUTPUT ACCEPT [0:0]
- -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
- -A INPUT -p icmp -j ACCEPT
- -A INPUT -i lo -j ACCEPT
- -A INPUT -m state --state NEW -m tcp -p tcp --dport 22 -j ACCEPT
- #添加配置项
- -A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT
- -A INPUT -m state --state NEW -m tcp -p tcp --dport 11211 -j ACCEPT
- -A INPUT -m state --state NEW -m tcp -p tcp --dport 3306 -j ACCEPT
- -A INPUT -j REJECT --reject-with icmp-host-prohibited
- -A FORWARD -j REJECT --reject-with icmp-host-prohibited
- COMMIT
11.重启防火墙
- [root@bogon etc]# service iptables restart
这样就可以从外部访问mysql了。
至此,mysql在CentOS6.5上的安装过程、用户创建、外部访问的步骤全部完成。
centos6.5下安装mysql的更多相关文章
- 建站笔记1:centos6.5下安装mysql
近期买了个域名,想要玩玩自己建站点:接下来遇到的问题都会一次记录下来.以备自己以后复习查看: 首先建站方案选择: wordPress +centos6.5 +mysql; server买的:搬瓦工最低 ...
- centos6.5下安装mysql数据库
centos6.5下安装mysql数据库 1.安装mysql数据库:yum install mysql-server 2.临时启动数据库:service mysqld start 3.开机启动数据库: ...
- centos6.4下安装mysql
一.mysql简介 说到数据库,我们大多想到的是关系型数据库,比如mysql.oracle.sqlserver等等,这些数据库软件在windows上安装都非常的方便,在Linux上如果要安装数据库,咱 ...
- CentOS6.8下安装mysql
转自https://blog.csdn.net/jeffleo/article/details/53559712?utm_source=itdadao&utm_medium=referral ...
- CentOS6.7下安装MySQL
第一步:到MySQL官网上下载linux版本的MySQL rpm 安装包. 第二步: 将该压塑包解压后,有如下文件: 第三步:安装文件,我们需要安装的文件有 MySQL-server-5.6.26-1 ...
- linux centos6.8 下安装mysql 步骤
安装环境:vmware12.centos6.8.centos中配置阿里云数据元 1.下载mysql 运行: sudo yum -y install mysql-server 如果下载失败,可以卸载重新 ...
- CentOS6.5下安装配置MySQL
CentOS6.5下安装配置MySQL,配置方法如下: 安装mysql数据库:# yum install -y mysql-server mysql mysql-deve 查看mysql-server ...
- Mysql系列三:Centos6下安装Mysql和Mysql主从复制的搭建
一.Centos6下安装Mysql 检测下系统有没有自带的mysql:yum list installed | grep mysql, 如果已经有的话执行命令yum -y remove mysql-l ...
- 【转】CentOS6下安装mysql后,重置root密码方法
本文转自:CentOS6下安装mysql后,重置root密码方法 centos下安装mysql,居然不知道root用户密码,本想重装,不过还是先度娘了一些,发现这篇文章,刚好解决我的燃眉之急,太赞了. ...
随机推荐
- C#基础之IEnumerable
1.IEnumerable的作用 在使用Linq查询数据时经常以IEnumerable<T>来作为数据查询返回对象,在使用foreach进行遍历时需要该对象实现IEnumerable接口, ...
- ASP.NET网站入侵第三波(fineui系统漏洞,可导致被拖库)
注:屏蔽本漏洞的紧急通知:http://fineui.com/bbs/forum.php?mod=viewthread&tid=7863 本人小学文化,文采不好,写的不好请各位多多包含, 最近 ...
- .Net分布式异常报警系统-服务端站点管理
管理站点 对于管理站点, 并没有太复杂的内容, 主要就是对数据库表中的数据进行维护. 管理的实体有3个 WebSite(站点信息), WebService(站点服务器信息), ErrorEntity ...
- js的offsetWidth,offsetHeight,offsetLeft,offsetTop
js的offsetWidth,offsetHeight,offsetLeft,offsetTop
- [【codechefCHSEQ22】Chef and Favourite Sequence(并查集)
题目:http://hzwer.com/3419.html 题意:给你一个全是0的数列,有m种操作[Li,Ri],每次操作就将下标处于[Li,Ri]的元素取反.你可以选若干个操作来使这个数列最后变成别 ...
- 服务链(Service Chaining,or Service Function Chaining,SFC,功能服务链)
Software-configured service chaining provides the capability to dynamically include best-of-b ...
- C++ vector用法
在c++中,vector是一个十分有用的容器,下面对这个容器做一下总结. 1 基本操作 (1)头文件#include<vector>. (2)创建vector对象,vector<in ...
- .net MVC全球化资源使用心得
网上有的我就不说了,我只记录下我碰壁的事情. local资源就不说,这里只说global全局资源文件. 假设新建一个资源文件名称叫做resourceA, 下面几点记录备忘: resouceA就是Get ...
- Beta项目冲刺 --第一天
新的开始.. 队伍:F4 成员:031302301 毕容甲 031302302 蔡逸轩 031302430 肖阳 031302418 黄彦宁 会议内容: 1.站立式会议照片: 2.项目燃尽图 3.冲刺 ...
- jquery validate 隐藏域内容验证