Centos下我常用的一些命令
- 1.在centos下查看局域网ip
- ifconfig -a
- 2.查看是否安装了mysql
- rpm -qa | grep mysql
- 3.删除原有的mysql
- rpm -e mysql // 普通删除模式
- rpm -e --nodeps mysql
- 4.查看yum上可用的mysql版本
- yum list | grep mysql
- 5.通过yum安装mysql
- yum install -y mysql-server mysql mysql-devel
- 6.查看mysql安装版本
- rpm -qi mysql-server
- 7.开启mysql服务
- service mysqld start
- 8.设置mysql开机自启动
- chkconfig mysqld on
- 9.删除yum上存在的包
- yum -y remove mysql-libs*
- 10.通过rpm安装mysql
- rpm -ivh MySQL-client-5.6.33-1.el6.x86_64.rpm
- 11.初始化mysql及设置密码
- /usr/bin/mysql_install_db
- service mysql start
- cat /root/.mysql_secret
- mysql -uroot -p初始密码
- set PASSWORD=PASSWORD('123456');
- exit
- 12.开启远程访问
- mysql -uroot -p123456
- use mysql;
- update user set password=password('123456') where user='root';
- update user set host='%' where user='root' and host='localhost';
- flush privileges;
- exit
- 13.优化my.cnf配置文件
- vim /etc/my.cnf
- [mysqld]
- port = 3306
- default-storage-engine = InnoDB
- lower_case_table_names = 1
- max-connections=3000
- character_set_server=utf8
- [mysql]
- default-character-set=utf8
- =============解压缩相关====================
- 压缩
- tar -cvf jpg.tar *.jpg //将目录里所有jpg文件打包成tar.jpg
- tar -czf jpg.tar.gz *.jpg //将目录里所有jpg文件打包成jpg.tar后,并且将其用gzip压缩,生成一个gzip压缩过的包,命名为jpg.tar.gz
- tar -cjf jpg.tar.bz2 *.jpg //将目录里所有jpg文件打包成jpg.tar后,并且将其用bzip2压缩,生成一个bzip2压缩过的包,命名为jpg.tar.bz2
- tar -cZf jpg.tar.Z *.jpg //将目录里所有jpg文件打包成jpg.tar后,并且将其用compress压缩,生成一个umcompress压缩过的包,命名为jpg.tar.Z
- rar a jpg.rar *.jpg //rar格式的压缩,需要先下载rar for linux
- zip jpg.zip *.jpg //zip格式的压缩,需要先下载zip for linux
- 解压
- tar -xvf file.tar //解压 tar包
- tar -xzvf file.tar.gz //解压tar.gz
- tar -xjvf file.tar.bz2 //解压 tar.bz2
- tar -xZvf file.tar.Z //解压tar.Z
- unrar e file.rar //解压rar
- unzip file.zip //解压zip
- 1、*.tar 用 tar -xvf 解压
- 2、*.gz 用 gzip -d或者gunzip 解压
- 3、*.tar.gz和*.tgz 用 tar -xzf 解压
- 4、*.bz2 用 bzip2 -d或者用bunzip2 解压
- 5、*.tar.bz2用tar -xjf 解压
- 6、*.Z 用 uncompress 解压
- 7、*.tar.Z 用tar -xZf 解压
- 8、*.rar 用 unrar e解压
- 9、*.zip 用 unzip 解压
- ===========文件操作==============
- 删除文件夹实例:
- rm -rf /var/log/httpd/access
- 将会删除/var/log/httpd/access目录以及其下所有文件、文件夹
- 2
- 删除文件使用实例:
- rm -f /var/log/httpd/access.log
- 将会强制删除/var/log/httpd/access.log这个文件
- ===========MYSQL=================
- 1.查看mysql数据路径
- show variables like 'datadir'
- 2.查看数据库当前连接数
- show variables like '%max_connections%'
- =========Linux关闭防火墙=========
- 1.永久性生效,重启后不会复原
- 开启:chkconfig iptables on
- 关闭:chkconfig iptables off
- 2. 即时生效,重启后复原
- 开启:service iptables start
- 关闭:service iptables stop
- #解决mysql无法远程登陆
- 1.获得su最高权限
- 2. 尝试在107上的防火墙上加上端口的允许
- iptables -I INPUT -s 0/0 -p tcp --dport 3306 -j ACCEPT
- 3.访问端口3306,都会被允许的
- iptables -L -n|grep 3306
- #开放防火墙
- [root@centos httpd]# /sbin/iptables -I INPUT -p tcp --dport 80 -j ACCEPT
- [root@centos httpd]# /etc/rc.d/init.d/iptables save #不加此行关机后将不生效
- [root@centos httpd]# service iptables restart
- #查看某目录大小
- [root@localhost local]# du -hs smgpdfd
- 3.3G smgpdfd

低调大师中文资讯倾力打造互联网数据资讯、行业资源、电子商务、移动互联网、网络营销平台。
持续更新报道IT业界、互联网、市场资讯、驱动更新,是最及时权威的产业资讯及硬件资讯报道平台。
转载内容版权归作者及来源网站所有,本站原创内容转载请注明来源。
- 上一篇
Linux下xargs命令
1.功能: xargs可以将stdin中以空格或换行符进行分隔的数据,形成以空格分隔的参数(arguments),传递给其他命令。因为以空格作为分隔符,所以有一些文件名或者其他意义的名词内含有空格的时候,xargs可能会误判。简单来说,xargs是给其他命令传递参数的一个过滤器,是构建单行命令的重要组件之一。 之所以要用到xargs,是因为由于很多命令不支持使用管道|来传递参数,例如: find /sbin -perm +700 |ls -l //这个命令是错误,因为标准输入不能作为ls的参数 find /sbin -perm +700 |xargs ls -l //这样才是正确的 2.命令格式 xargs [选项] [command] 3.选项说明: -0:如果输入的stdin含有特殊字符,例如反引号`、反斜杠\、空格等字符时,xargs可以将它还原成一般字符。为xargs的默认选项。 -e <flag>,-E <flag>,--eof=<eof-str>:eof是end of file string的意思。flag可以是一个字符串...
- 下一篇
linux下开机以某一个用户执行脚本
1 . 编辑: /etc/rc.local 添加想要被执行的命令即可(默认是以root用户执行)。 注: 有些很特殊的情况/etc/rc.local不会被执行,可以 编辑/etc/init.d/rc.localsee link:http://www.linuxidc.com/Linux/2016-12/138665.htm 2 . 以期望的用户执行命令: su -c 'ls -l "myfile.txt"' guowei & 解释: 其中需要被执行的命令是ls -l "myfile.txt", 期望的用户的guowei,&表示在后台运行。 3 . 开机以 screen 运行程序脚本,并添加环境变量(no-login): #!/bin/bash # 环境变量要在 su 之前设置好,然后 sudo -E 保持环境变量 # 如果直接是root用户执行该脚本,则只需要 su -p 或者 su -m 保持环境变量即可 export GUOWEI_DIR=/home/guowei export PATH=/opt/bin:$PATH source /hom...
相关文章
文章评论
共有0条评论来说两句吧...
文章二维码
点击排行
推荐阅读
最新文章
- CentOS6,7,8上安装Nginx,支持https2.0的开启
- CentOS8安装MyCat,轻松搞定数据库的读写分离、垂直分库、水平分库
- Windows10,CentOS7,CentOS8安装Nodejs环境
- CentOS7设置SWAP分区,小内存服务器的救世主
- CentOS关闭SELinux安全模块
- Docker安装Oracle12C,快速搭建Oracle学习环境
- Docker快速安装Oracle11G,搭建oracle11g学习环境
- CentOS7编译安装Gcc9.2.0,解决mysql等软件编译问题
- 2048小游戏-低调大师作品
- SpringBoot2更换Tomcat为Jetty,小型站点的福音