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

 

最新文章

  1. EC笔记:第三部分:16成对使用new和delete
  2. .NET LINQ查询语法与方法语法
  3. *** Assertion failure in -[UIApplication _runWithMainScene:transitionContext iOS9.1闪退问题解决
  4. Performance Analysis Methodology
  5. ViewPager的监听事件失效
  6. [Everyday Mathematics]20150303
  7. U3D 收藏一个飞机随机运动的方法
  8. Java ---自定义标签
  9. JavaScript中apply与call方法
  10. dbda数据库类
  11. [Machine Learning]学习笔记-线性回归
  12. 【编程技巧】EXTJS中Ext.grid.GridPanel配置项autoExpandColumn的使用方法
  13. 特殊权限SUIG、SGID、SBIT
  14. CRM客户关系管理系统(八)
  15. sqlserver笔记----创建用户赋予权限
  16. 叮咚,你的Lauce上线了!
  17. 单元测试系列之五:Mock工具之Mockito实战
  18. mac node版本管理
  19. oauth2 java 代码示例
  20. 有趣的HTML5 CSS3效果

热门文章

  1. HDU 5791 Two(训练题002 F)
  2. asp.net应用发布到IIS无法链接到oracle数据库
  3. 解决ajax的parsererror错误的终极办法(后台传给前台的数据json问题)
  4. 项目实战2.2—nginx 反向代理负载均衡、动静分离和缓存的实现
  5. JS--我发现,原来你是这样的JS:面向对象编程OOP[3]--(JS继承)
  6. 获取所有栈的信息,只有最上面的和最下面的,但是不能获取栈中间的activity信息
  7. [转载] Hadoop MapReduce
  8. 使用flex
  9. Facebook-Haystack合并小文件
  10. python操作Mysql基础