作者:小东东5201314 | 来源:互联网 | 2017-05-12 15:07
vim编辑模式下可以显示行数ldquo;sudovietcvimvimrcrdquo;在打开的文件中加入ldquo;setnurdquo;保存后退出。利用:r
vim 编辑模式下可以显示行数ldquo;sudo vi /etc/vim/vimrcrdquo;在打开的文件中加入ldquo;set nurdquo;保存后退出。利用:r
vim 编辑模式下可以显示行数“sudo vi /etc/vim/vimrc”在打开的文件中加入“set nu”保存后退出。
利用:”vi .bash_history“查看之前输入过的命令
编译操作数据库的程序test.c时 输入”./test“提示错误:
Connection error 2002: Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)
此时更改mysql下进行数据库连接时的mysql_real_connect(&mysql, "localhost", "localhost", "", "myclink", 0, NULL, 0)其中的第一个localhost换为”127.0.0.1“,记得输入密码”111“
编译操作数据库的程序test.c时 输入”./test”提示错误:./test: error while loading shared libraries: libmysqlclient.so.18: cannot open shared object file: No such file or directory,此时用命令”export“查看环境变量,发现没有mysql的lib的路径,此时输入”vi .bashrc“,在末尾行输入”export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/mysql/lib“将该路径动态添加到环境变量(如果直接在export中间添加,则属于session对话,此时对环境变量的改变属于临时改变,在该对话结束后,环境变量会恢复为以前的状态,而.bashrc在每次编译时会动态执行一次,故可以一次写入,,每次调用.bashrc将环境变量添加进去)
输入 gcc -o test $(./mysql_config --cflags) test.c $(./mysql_config –libs)
编译时,提示错误信息:
bash: ./mysql_config:
No such file or directorybash: ./mysql_config:
No such file or directorytest.c: In function ‘main’:test.c:36:50:
warning: incompatible implicit declaration of built-in function ‘strlen’/tmp/ccfnwW6I.o:
In function `main':test.c:(.text+0xa9): undefined reference to `mysql_init'test.c:(.text+0xed): undefined reference to `mysql_real_connect'test.c:(.text+0xfd):
undefined reference to `mysql_error'test.c:(.text+0x14f):
undefined reference to `mysql_real_query'test.c:(.text+0x166):
undefined reference to `mysql_error'test.c:(.text+0x1a2):
undefined reference to `mysql_close'collect2:
ld returned 1 exit status,
此时将mysql_config复制到程序当前路径下并命名为mysql_config,输入
”cp ./workspace/insert/mysql_config ./mysql_config“
此时”ls“看到当前目录下复制了一个mysql_config文件,
输入 gcc -o test $(./mysql_config --cflags) test.c $(./mysql_config –libs)
再输入”gcc -o test $(./mysql_config --cflags) test.c $(./mysql_config –libs)”
此时在该目录下生成可执行文件test