|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
如果您觉得本篇CentOSLinux教程讲得好,请记得点击右边漂浮的分享程序,把好文章分享给你的好朋友们!1.利用yum下令装置mysql
[html]viewplaincopy
http://static.blog.csdn.net/scripts/ZeroClipboard/ZeroClipboard.swf
- [root@bogon~]#yum-yinstallmysql-server
2.设置开机启动
[html]viewplaincopy
http://static.blog.csdn.net/scripts/ZeroClipboard/ZeroClipboard.swf
- [root@bogon~]#chkconfigmysqldon
3.启动MySQL办事
[html]viewplaincopy
http://static.blog.csdn.net/scripts/ZeroClipboard/ZeroClipboard.swf
- [root@bogon~]#servicemysqldstart
4.设置MySQL的root用户设置暗码
[html]viewplaincopy
http://static.blog.csdn.net/scripts/ZeroClipboard/ZeroClipboard.swf
- [root@bogon~]#mysql-uroot
- mysql>selectuser,host,passwordfrommysql.user;
- +------+-----------+----------+
- |user|host|password|
- +------+-----------+----------+
- |root|localhost||
- |root|bogon||
- |root|127.0.0.1||
- ||localhost||
- ||bogon||
- +------+-----------+----------+
- 5rowsinset(0.01sec)
查询用户的暗码,都为空,用上面的下令设置root的暗码为root
[html]viewplaincopy
http://static.blog.csdn.net/scripts/ZeroClipboard/ZeroClipboard.swf
- mysql>setpasswordforroot@localhost=password(root);
- mysql>exit
5.用新暗码上岸
[html]viewplaincopy
http://static.blog.csdn.net/scripts/ZeroClipboard/ZeroClipboard.swf
- [root@bogon~]#mysql-uroot-p
- Enterpassword:
6.创立mysql新用户test_user
[html]viewplaincopy
http://static.blog.csdn.net/scripts/ZeroClipboard/ZeroClipboard.swf
- mysql>createusertest_user@%identifiedbytest_user;
- QueryOK,0rowsaffected(0.00sec)
7.给新用户test_user受权,让他能够从内部上岸和当地上岸
注重:@右边是用户名,右侧是域名、IP和%,暗示能够会见mysql的域名和IP,%暗示内部任何地点都能会见。
[html]viewplaincopy
http://static.blog.csdn.net/scripts/ZeroClipboard/ZeroClipboard.swf
- mysql>grantallprivilegeson*.*totest_user@localhostidentifiedbytest_user;
- QueryOK,0rowsaffected(0.00sec)
- mysql>grantallprivilegeson*.*totest_user@%identifiedbytest_user;
- QueryOK,0rowsaffected(0.00sec)
- mysql>selectuser,host,passwordfrommysql.user;
- +----------+-----------+-------------------------------------------+
- |user|host|password|
- +----------+-----------+-------------------------------------------+
- |root|localhost|*81F5E21E35407D884A6CD4A731AEBFB6AF209E1B|
- |root|bogon||
- |root|127.0.0.1||
- ||localhost||
- ||bogon||
- |test_user|%|*3046CF87132BBD4FDDF06F321C6859074843B7D3|
- |test_user|localhost|*3046CF87132BBD4FDDF06F321C6859074843B7D3|
- +----------+-----------+-------------------------------------------+
- 7rowsinset(0.00sec)
- mysql>flushprivileges;
- QueryOK,0rowsaffected(0.01sec)
8.检察mysql5.1的默许存储引擎
从上面的实行了局能够看出,mysql的默许引擎是MyISAM,这个引擎是不撑持事件的。
[html]viewplaincopy
http://static.blog.csdn.net/scripts/ZeroClipboard/ZeroClipboard.swf
- mysql>showengines;
- +------------+---------+------------------------------------------------------------+--------------+------+------------+
- |Engine|Support|Comment|Transactions|XA|Savepoints|
- +------------+---------+------------------------------------------------------------+--------------+------+------------+
- |MRG_MYISAM|YES|CollectionofidenticalMyISAMtables|NO|NO|NO|
- |CSV|YES|CSVstorageengine|NO|NO|NO|
- |MyISAM|DEFAULT|DefaultengineasofMySQL3.23withgreatperformance|NO|NO|NO|
- |InnoDB|YES|Supportstransactions,row-levellocking,andforeignkeys|YES|YES|YES|
- |MEMORY|YES|Hashbased,storedinmemory,usefulfortemporarytables|NO|NO|NO|
- +------------+---------+------------------------------------------------------------+--------------+------+------------+
- 5rowsinset(0.00sec)
也能够以上面的体例检察
[html]viewplaincopy
http://static.blog.csdn.net/scripts/ZeroClipboard/ZeroClipboard.swf
- mysql>showvariableslikestorage_engine;
- +----------------+--------+
- |Variable_name|Value|
- +----------------+--------+
- |storage_engine|MyISAM|
- +----------------+--------+
- 1rowinset(0.00sec)
9.修正mysql的默许引擎为InnoDB
9.1中断mysql
[html]viewplaincopy
http://static.blog.csdn.net/scripts/ZeroClipboard/ZeroClipboard.swf
- mysql>exit;
- [root@bogon~]#servicemysqldstop
9.2修正/etc/my.cnf
[mysqld]后到场
[html]viewplaincopy
http://static.blog.csdn.net/scripts/ZeroClipboard/ZeroClipboard.swf
- default-storage-engine=InnoDB
到场后my.cnf的内容为:
<divclass="dp-highlighterbg_html"style="font-family:Consolas,CourierNew,Courier,mono,serif;background-color:rgb(231,229,220);width:700.9166870117188px;overflow:auto;padding-top:1px;margin:18px0px!important;color:rgb(51,51,51);line-height:26px;">[html]viewplaincopy
http://static.blog.csdn.net/scripts/ZeroClipboard/ZeroClipboard.swf
<olclass="dp-xml"start="1"style="margin:0px0px1px45px!important;padding-right:0px;padding-left:0px;border:none;list-style-position:initial;list-style-image:initial;background-color:rgb(255,255,255);color:rgb(92,92,92);"><liclass="alt"style="margin:0px!important;padding:0px3px0px10px!important;border-style:nonenonenonesolid;border-left-width:3px;border-left-color:rgb(108,226,108);list-style:decimal-leading-zerooutside;color:inherit;line-height:18px;">[root@bogonetc]#moremy.cnf<listyle="margin:0px!important;padding:0px3px0px10px!important;border-style:nonenonenonesolid;border-left-width:3px;border-left-color:rgb(108,226,108);list-style:decimal-leading-zerooutside;background-color:rgb(248,248,248);line-height:18px;">[mysqld]<liclass="alt"style="margin:0px!important;padding:0px3px0px10px!important;border-style:nonenonenonesolid;border-left-width:3px;border-left-color:rgb(108,226,108);list-style:decimal-leading-zerooutside;color:inherit;line-height:18px;">datadir=/var/lib/mysql<listyle="margin:0px!important;padding:0px3px0px10px!important;border-style:nonenonenonesolid;border-left-width:3px;border-left-color:rgb(108,226,108);list-style:decimal-leading-zerooutside;background-color:rgb(248,248,248);line-height:18px;">socket=/var/lib/mysql/mysql.sock<liclass="alt"style="margin:0px!important;padding:0px3px0px10px!important;border-style:nonenonenonesolid;border-left-width:3px;border-left-color:rgb(108,226,108);list-style:decimal-leading-zerooutside;color:inherit;line-height:18px;">user=mysql |
|