1.windows自带命令进入mysql所在磁盘
 
2.进入mysql安装目录的bin文件
D:\>cd D:\Program Files (x86)\mysql-5.5.25-winx64\bin
 
3.登录mysql数据库
D:\Program Files (x86)\mysql-5.5.25-winx64\bin>mysql.exe -uroot -p123456 -h127.0.0.1 -P3306
 
接下来之后就可以操作mysql数据库了
 
mysql创建数据库指定字符集
CREATE DATABASE `test2` DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;
 
重启tomcat
/opt/appstack/ctlscript.sh restart tomcat
 
导出数据库的命令行:
mysqldump -u 数据库用户名 -p 数据库名称 > 导出的数据库文件
         实例:mysqldump -u root -p db1>g:\liongg.sql (把数据库db1 导出到 liongg.sql 文件中)
         回车之后,会提示输入密码,有则输入无则直接回车,片刻即可成功。
 
导出整个数据库
mysqldump -u用户名 -p密码 -hIP -P端口号 数据库名 --hex-blob>D:\mysqldump_dir\liongg.sql
 
只导出数据库表结构
mysqldump -u用户名 -p密码 -hIP -P端口号 数据库名 --opt -d>D:\mysqldump_dir\liongg_ddl.sql
 
只导出数据库表数据
mysqldump -u用户名 -p密码 -hIP -P端口号 数据库名 -t>D:\mysqldump_dir\liongg_dml.sql
 
 
导入数据库的命令行:
1.mysql -u 数据库用户名 –p 数据库名称 < 导入的数据库文件
         实例:mysqldump -u root -p db2<g:\liongg.sql; (已新建数据库db2,把liongg.sql导入)
2.先登录数据库,use database ;然后使用source sql文件路径就可以导入了。
3.导入数据库mysqlimport -u root -p123456 < g:\liongg.sql;
 
 
mysql允许远程连接,设置权限
grant 权限 on 数据库名.表名 to '用户名'@'IP地址' identified by '密码' with grant option;
grant all privileges *.* to 'root'@'%' identified by '123456' with grant option;
 
revoke 权限 on 数据库名.表名 from '用户名'@'IP地址';
revoke all privileges *.* from 'root'@'%';
 
 
window dos命令
md mysqldump_dir   创建文件夹
ECHO 文件内容>文件名.txt  创建文件
ECHO 文件内容追加入>>文件名.txt  创建文件
copy con 文件名
然后输入文件内容后按ctrl+z结束,文件就建立了
 
del 只能删除同一文件夹的文件
rd /s 文件夹名  可以删除文件夹及文件夹里面的所以东西
 
 
linux dos命令
man 提示命令
mkdir mysqldump_dir   创建文件夹
touch 文件名.txt  创建文件
 
 
rm 只能删除同一文件夹的文件
rm -r 文件夹名  可以删除文件夹及文件夹里面的所以东西(r代表递归)
 
gz命令文件处理
压缩:tar -zcvf FileName.tar.gz 路径/压缩文件名
解压:tar -zxvf 路径/FileName.tar.gz
 
vim  查看文件
/关键字  查找文件 按 n 查找下一处,按 N 查找上一处
从第一行到最后一行,把utf8mb4替换成utf8   :1:$ s/utf8mb4/utf8/g    或   :g/utf8mb4/s//utf8/g
vim查看文件之后按 i 编辑文件,按esc退出编辑
 
给文件夹赋权限
chown -R tomcat:tomcat  /opt/files
 
 

[root@VM_64_7_centos tmp]# id
uid=0(root) gid=0(root) groups=0(root)
[root@VM_64_7_centos tmp]# id test
id: test: no such user
[root@VM_64_7_centos tmp]# id root
uid=0(root) gid=0(root) groups=0(root)
[root@VM_64_7_centos tmp]# useradd test
[root@VM_64_7_centos tmp]# id
uid=0(root) gid=0(root) groups=0(root)
[root@VM_64_7_centos tmp]# id test
uid=1000(test) gid=1000(test) groups=1000(test)
[root@VM_64_7_centos tmp]# gpasswd -a test root
Adding user test to group root
[root@VM_64_7_centos tmp]# id test
uid=1000(test) gid=1000(test) groups=1000(test),0(root)
[root@VM_64_7_centos tmp]# gpasswd -d test root
Removing user test from group root
[root@VM_64_7_centos tmp]# id test
uid=1000(test) gid=1000(test) groups=1000(test)
[root@VM_64_7_centos ~]# passwd test
Changing password for user test.
New password:
Retype new password:
passwd: all authentication tokens updated successfully.
[test@VM_64_7_centos tmp]$ id
uid=1000(test) gid=1000(test) groups=1000(test)
[test@VM_64_7_centos tmp]$ su - root
Password:
[root@VM_64_7_centos tmp]# id
uid=0(root) gid=0(root) groups=0(root)
[root@VM_64_7_centos tmp]#
[root@VM_64_7_centos tmp]# userdel -r test
[root@VM_64_7_centos tmp]# id test
id: test: no such user

[root@VM_64_7_centos tmp]# ls -l
total 8
-r--r--r-- 1 root root 616 Dec 18 13:48 test.sh
[root@VM_64_7_centos tmp]# chmod g+w o+x ./test.sh
chmod: cannot access 'o+x': No such file or directory
[root@VM_64_7_centos tmp]# chmod g+w ./test.sh
[root@VM_64_7_centos tmp]# ls -l
total 8
-r--rw-r-- 1 root root 616 Dec 18 13:48 test.sh
[root@VM_64_7_centos tmp]# chmod u+wx ./test.sh
[root@VM_64_7_centos tmp]# ls -l
total 8
-rwxrw-r-- 1 root root 616 Dec 18 13:48 test.sh
[root@VM_64_7_centos tmp]# chmod o+x ./test.sh
[root@VM_64_7_centos tmp]# ls -l
total 8
-rwxrw-r-x 1 root root 616 Dec 18 13:48 test.sh
[root@VM_64_7_centos tmp]# chmod a-rwx ./test.sh
[root@VM_64_7_centos tmp]# ls -l
total 8
---------- 1 root root 616 Dec 18 13:48 test.sh
[root@VM_64_7_centos tmp]# chmod u+rwx ./test.sh
[root@VM_64_7_centos tmp]# ls -l
total 8
-rwx------ 1 root root 616 Dec 18 13:48 test.sh

[root@VM_64_7_centos tmp]# ls -l
total 8
-rwx------ 1 root root 616 Dec 18 13:48 test.sh
[root@VM_64_7_centos tmp]# chmod 000 ./test.sh
[root@VM_64_7_centos tmp]# ls -l
total 8
---------- 1 root root 616 Dec 18 13:48 test.sh
[root@VM_64_7_centos tmp]# chmod u+001 ./test.sh
chmod: invalid mode: 'u+001'
Try 'chmod --help' for more information.
[root@VM_64_7_centos tmp]# chmod 001 ./test.sh
[root@VM_64_7_centos tmp]# ls -l
total 8
---------x 1 root root 616 Dec 18 13:48 test.sh
[root@VM_64_7_centos tmp]# chmod 020 ./test.sh
[root@VM_64_7_centos tmp]# ls -l
total 8
-----w---- 1 root root 616 Dec 18 13:48 test.sh
[root@VM_64_7_centos tmp]# chmod 400 ./test.sh
[root@VM_64_7_centos tmp]# ls -l
total 8
-r-------- 1 root root 616 Dec 18 13:48 test.sh
[root@VM_64_7_centos tmp]# chmod 600 ./test.sh
[root@VM_64_7_centos tmp]# ls -l
total 8
-rw------- 1 root root 616 Dec 18 13:48 test.sh
[root@VM_64_7_centos tmp]# chmod 700 ./test.sh
[root@VM_64_7_centos tmp]# ls -l
total 8
-rwx------ 1 root root 616 Dec 18 13:48 test.sh
[root@VM_64_7_centos tmp]# chmod 744 test.sh
[root@VM_64_7_centos tmp]# ls -l
total 8
-rwxr--r-- 1 root root 616 Dec 18 13:48 test.sh
[root@VM_64_7_centos tmp]#

[root@VM_64_7_centos tmp]# getfacl test.sh
# file: test.sh
# owner: root
# group: root
user::rwx
group::r-x
other::r-x

[root@VM_64_7_centos tmp]# setfacl -m u:test:rwx test.sh
[root@VM_64_7_centos tmp]# getfacl test.sh
# file: test.sh
# owner: root
# group: root
user::rwx
user:test:rwx
group::r-x
mask::rwx
other::r-x

[root@VM_64_7_centos tmp]# setfacl -x user:test test.sh
[root@VM_64_7_centos tmp]# getfacl test.sh
# file: test.sh
# owner: root
# group: root
user::rwx
group::r-x
mask::r-x
other::r-x

[root@VM_64_7_centos tmp]# ls -l
total 8
-rwxr-xr-x+ 1 root root 616 Dec 18 13:48 test.sh
[root@VM_64_7_centos tmp]# setfacl -b test.sh
[root@VM_64_7_centos tmp]# getfacl test.sh
# file: test.sh
# owner: root
# group: root
user::rwx
group::r-x
other::r-x

[root@VM_64_7_centos tmp]#

运行结果:

[root@VM_64_7_centos tmp]# ls -l
total 8
---------- 1 root root 616 Dec 18 13:48 test.sh
[root@VM_64_7_centos tmp]# bash test.sh

current sh file name ./test.sh ./test.sh ./test.sh_file
10470
total value is:4
10 * 20 = 200
a==b or a>0
9
file enable write
file is not empty
0
1
2
a
b
c
array length is 3; array contain element is: a b c
5
6
call count function 10+20=30

[root@VM_64_7_centos tmp]# ./test.sh
-bash: ./test.sh: Permission denied

sheel脚本内容:

#! /bin/bash
echo "current sh file name $0 ${0} $0_file"
echo $$
value=`expr 2 + 2`
echo "total value is:${value}"
a=10
b=20
ab=`expr $a \* $b`
echo "$a * $b = $ab"

#echo "please inputi c:"
#read c
#ab=`expr $a / $c`
#echo "$a/$c=${ab}"

if [ $a == $b -o $a -gt 0 ];
then
echo "a==b or a>0"
else
echo "a!=b"
fi

str="dog,cat,fish,cattle,pig,rabbit"
echo `expr index $str fish`

file="/usr/tmp/file.test"
if [ -e ${file} ]
then
if [ -w $file ]
then
echo "file enable write"
fi
if [ -s $file ]
then
echo "file is not empty"
else
echo "file is empty"
fi
fi

#loop
for ((i=0;i<3;i++))
do echo $i
done

#array=(a b c)
array[0]=a
array[1]=b
array[2]=c
for i in ${array[@]}
do echo $i
done
echo "array length is" ${#array[@]}"; array contain element is:" ${array[@]}

j=5
while [ $j -lt 7 ]
do
echo $j
j=$(($j+1))
done

name=bird
case $name in
dog)
echo $name;;
cat)
echo $name;;
fish)
echo $name;;
rabbit)
echo $name;;
esac

total=0
count(){
total=$(($1+$2))
}

count 10 20
echo "call count function 10+20=$total"

echo ${array[@]} >> /usr/tmp/file.test

<<EOF

read var
echo "You input is $var"
EOF

 

Linux基础学习笔记以及常用命令的更多相关文章

  1. 【Linux基础学习】Ubuntu 常用命令大全

    一.文件目录类 1.建立目录:mkdir 目录名 2.删除空目录:rmdir 目录名 3.无条件删除子目录: rm -rf 目录名 4.改变当前目录:cd 目录名 (进入用户home目录:cd ~:进 ...

  2. git学习笔记:常用命令总结

    本文根据廖雪峰的博客,记录下自己的学习笔记.主要记录常用的命令,包括仓库初始化.添加文件.提交修改.新建分支.内容暂存.分支管理.标签管理等内容. git是分布式版本控制系统. 首先是安装,从官网下载 ...

  3. Linux基础学习笔记6-SHELL编程

    编程基础 程序:指令+数据 程序编程风格: 过程式:以指令为中心,数据服务于指令 对象式:以数据为中心,指令服务于数据 shell程序:提供了编程能力,解释执行 编程基本概念: 顺序执行:循环执行:选 ...

  4. Linux基础学习笔记4-文本处理

    本章内容 抽取文本的工具 文件内容:less和cat 文件截取:head和tail 按列抽取:cut 按关键字抽取:grep 文件查看 文件查看命令:cat,tac,rev cat [OPTION] ...

  5. linux基础(4)-常用命令

    常用命令ls ls #查看当前目录下的文件和目录 ls -l #显示详细信息 ls -a #显示所有文件 ls -t #按修改时间排序 ls -S #按文件大小排序   常用命令pwd pwd #显示 ...

  6. CentOS7学习笔记(四) 常用命令记录

    查看命令的帮助信息 man 命令查看帮助信息 在想要获取帮助信息的命令前面加上man即可,例如查看ls命令的帮助信息 [root@localhost ~]# man ls help 命令查看帮助信息 ...

  7. Linux学习笔记:常用命令

    个人常用的Linux命令总结(持续更新): 切换目录:cd 列出目录下面的文件:ls 显示当前所在的目录:pwd 操作文件 新建文件:touch file01 查看文件内容:less more cat ...

  8. Linux学习笔记:常用命令grep、iconv、cp、mv、rm

    本篇记录一些近期常用的命令. 一.grep过滤 grep过滤 不包含某些字符串 cat test.txt | grep -v '.jpg' 过滤jpg结尾的图片 cat test.txt | grep ...

  9. LInux学习笔记之常用命令

    以下命令主要是平时用到的命令,对于一些经常用到的,就收集资料,归纳一下. 指令目录: 1.yum命令: 2.wget命令: 3.tar命令: 4../configure,make,make insta ...

随机推荐

  1. nodejs运行前端项目

    有时候我们会创建一些小项目,只有几个简单html,没有引入一些前端框架,也没有使用webpack,那我们要如何让代码在我们本地跑起来呢? 当然是有很多种方法,IIS.wampserver等等好多都可以 ...

  2. 对抗栈帧地址随机化/ASLR的两种思路和一些技巧

    栈帧地址随机化是地址空间布局随机化(Address space layout randomization,ASLR)的一种,它实现了栈帧起始地址一定程度上的随机化,令攻击者难以猜测需要攻击位置的地址. ...

  3. c++ 类的默认八种函数

    c++ 类的默认八种函数 #define _CRT_SECURE_NO_WARNINGS #include <iostream> #include <string> #incl ...

  4. Problem D

    Problem Description An entropy encoder is a data encoding method that achieves lossless data compres ...

  5. ruby 异常处理 begin rescue end

    begin 代码1 rescue 代码 end 如果执行 代码1 发生异常 则转至 代码2 若正常,则执行完跳出

  6. mybatis取数据库为null的字段

    数据库中存在int型的字段,但是初始值为null,mybatis取值之后就会报错, org.apache.ibatis.binding.BindingException: Mapper method ...

  7. ADO.NET中SqlCommand对数据库操作

    我们要不断地进行数据库的读写,那么ExecuteNonQuery(),ExecuteReader()与ExecuteScalar()就是我们在对数据库进行操作时要用到的,下面我来依次认识一下:     ...

  8. asp.net web api 版本控制

    版本控制   版本控制的方法有很多,这里提供一种将Odata与普通web api版本控制机制统一的方法,但也可以单独控制,整合控制与单独控制主要的不同是:整合控制通过VersionController ...

  9. db2中left()函数和right()函数对应oracle中的substr()函数

     DB2 LEFT.RIGHT函数 语法:LEFT(ARG,LENGTH).RIGHT(ARG,LENGTH) LEFT.RIGHT函数返回ARG最左边.右边的LENGTH个字符串,ARG可以是CHA ...

  10. final、static、代码块、静态代码块、内部类、代码执行顺序

    final final域使得确保初始化安全性(initialization safety)成为可能,初始化安全性让不可变形对象不需要同步就能自由地被访问和共享 作用在类上               ...