您现在的位置是:首页 > 文章详情

Centos下我常用的一些命令

日期:2017-12-20点击:626
  1. 1.在centos下查看局域网ip    
  2. ifconfig -a  
  3.   
  4. 2.查看是否安装了mysql  
  5. rpm -qa | grep mysql  
  6.   
  7. 3.删除原有的mysql  
  8. rpm -e mysql // 普通删除模式  
  9. rpm -e --nodeps mysql  
  10.   
  11. 4.查看yum上可用的mysql版本  
  12. yum list | grep mysql  
  13.   
  14. 5.通过yum安装mysql  
  15. yum install -y mysql-server mysql mysql-devel  
  16.   
  17. 6.查看mysql安装版本  
  18. rpm -qi mysql-server  
  19.   
  20. 7.开启mysql服务  
  21. service mysqld start  
  22.   
  23. 8.设置mysql开机自启动  
  24. chkconfig mysqld on  
  25.   
  26. 9.删除yum上存在的包  
  27. yum -y remove mysql-libs*  
  28.   
  29. 10.通过rpm安装mysql  
  30. rpm -ivh MySQL-client-5.6.33-1.el6.x86_64.rpm  
  31.   
  32. 11.初始化mysql及设置密码  
  33. /usr/bin/mysql_install_db  
  34. service mysql start  
  35. cat /root/.mysql_secret  
  36. mysql -uroot -p初始密码  
  37. set PASSWORD=PASSWORD('123456');  
  38. exit  
  39.   
  40. 12.开启远程访问  
  41. mysql -uroot -p123456  
  42. use mysql;  
  43. update user set password=password('123456') where user='root';  
  44. update user set host='%' where user='root' and host='localhost';  
  45. flush privileges;  
  46. exit  
  47.   
  48. 13.优化my.cnf配置文件  
  49. vim /etc/my.cnf  
  50. [mysqld]  
  51. port = 3306  
  52. default-storage-engine = InnoDB   
  53. lower_case_table_names = 1   
  54. max-connections=3000  
  55. character_set_server=utf8  
  56. [mysql]    
  57. default-character-set=utf8  
  58.   
  59.   
  60.   
  61. =============解压缩相关====================  
  62. 压缩  
  63. tar -cvf jpg.tar *.jpg //将目录里所有jpg文件打包成tar.jpg   
  64. tar -czf jpg.tar.gz *.jpg   //将目录里所有jpg文件打包成jpg.tar后,并且将其用gzip压缩,生成一个gzip压缩过的包,命名为jpg.tar.gz  
  65. tar -cjf jpg.tar.bz2 *.jpg //将目录里所有jpg文件打包成jpg.tar后,并且将其用bzip2压缩,生成一个bzip2压缩过的包,命名为jpg.tar.bz2  
  66. tar -cZf jpg.tar.Z *.jpg   //将目录里所有jpg文件打包成jpg.tar后,并且将其用compress压缩,生成一个umcompress压缩过的包,命名为jpg.tar.Z  
  67. rar a jpg.rar *.jpg //rar格式的压缩,需要先下载rar for linux  
  68. zip jpg.zip *.jpg //zip格式的压缩,需要先下载zip for linux  
  69.   
  70. 解压  
  71. tar -xvf file.tar //解压 tar包  
  72. tar -xzvf file.tar.gz //解压tar.gz  
  73. tar -xjvf file.tar.bz2   //解压 tar.bz2  
  74. tar -xZvf file.tar.Z   //解压tar.Z  
  75. unrar e file.rar //解压rar  
  76. unzip file.zip //解压zip  
  77.   
  78. 1、*.tar 用 tar -xvf 解压  
  79. 2、*.gz 用 gzip -d或者gunzip 解压  
  80. 3、*.tar.gz和*.tgz 用 tar -xzf 解压  
  81. 4、*.bz2 用 bzip2 -d或者用bunzip2 解压  
  82. 5、*.tar.bz2用tar -xjf 解压  
  83. 6、*.Z 用 uncompress 解压  
  84. 7、*.tar.Z 用tar -xZf 解压  
  85. 8、*.rar 用 unrar e解压  
  86. 9、*.zip 用 unzip 解压  
  87.   
  88.   
  89. ===========文件操作==============  
  90. 删除文件夹实例:  
  91. rm -rf /var/log/httpd/access  
  92. 将会删除/var/log/httpd/access目录以及其下所有文件、文件夹  
  93. 2  
  94. 删除文件使用实例:  
  95. rm -f /var/log/httpd/access.log  
  96. 将会强制删除/var/log/httpd/access.log这个文件  
  97.   
  98.   
  99. ===========MYSQL=================  
  100. 1.查看mysql数据路径  
  101. show variables like 'datadir'  
  102. 2.查看数据库当前连接数  
  103. show variables like '%max_connections%'  
  104.   
  105. =========Linux关闭防火墙=========  
  106. 1.永久性生效,重启后不会复原  
  107. 开启:chkconfig iptables on  
  108. 关闭:chkconfig iptables off  
  109. 2. 即时生效,重启后复原  
  110. 开启:service iptables start  
  111. 关闭:service iptables stop  
  112.   
  113. #解决mysql无法远程登陆  
  114. 1.获得su最高权限  
  115. 2. 尝试在107上的防火墙上加上端口的允许  
  116. iptables -I INPUT -s 0/0 -p tcp --dport 3306 -j ACCEPT  
  117. 3.访问端口3306,都会被允许的  
  118. iptables -L -n|grep 3306  
  119.   
  120. #开放防火墙  
  121. [root@centos httpd]# /sbin/iptables -I INPUT -p tcp --dport 80 -j ACCEPT  
  122. [root@centos httpd]# /etc/rc.d/init.d/iptables save #不加此行关机后将不生效  
  123. [root@centos httpd]# service iptables restart     
  124.   
  125. #查看某目录大小  
  126. [root@localhost local]# du -hs smgpdfd  
  127. 3.3G    smgpdfd  
原文链接:https://www.centoschina.cn/command/help/9476.html
关注公众号

低调大师中文资讯倾力打造互联网数据资讯、行业资源、电子商务、移动互联网、网络营销平台。

持续更新报道IT业界、互联网、市场资讯、驱动更新,是最及时权威的产业资讯及硬件资讯报道平台。

转载内容版权归作者及来源网站所有,本站原创内容转载请注明来源。

文章评论

共有0条评论来说两句吧...

文章二维码

扫描即可查看该文章

点击排行

推荐阅读

最新文章