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