In Vim editing mode, the number of lines "sudo VI/etc/Vim/vimrc" can be displayed. Add "set nu" to the opened file and save the settings and exit.
Use: "vi. bash_history" to view the previously entered commands
If the system prompts that MySQL cannot be found. h. Enter the command sudo find/-name "MySQL. H "check whether the system has this header file. If yes, enter the absolute path of the file in include. If not, install libmysqld-Dev, enter sudo apt-Get install libmysqld-Dev. After installation, run the find command again and find that the file is already in/usr/include/MySQL. h path.
When compiling the database program test. C, enter "./test" with the following error message:
Connection error 2002: Can't connect to local MySQL server through socket '/tmp/MySQL. Sock' (2)
Change mysql_real_connect (& MySQL, "localhost", "localhost", "", "myclink", 0, null, 0) for database connection under MySQL) replace the first localhost with "127.0.0.1". Remember to enter the password "111".
Compile the database program test. enter ". /test "error :. /test: Error while loading shared libraries: libmysqlclient. so.18: cannot open shared object file: no such file or directory. Run the "Export" command to view the environment variables. If the Lib path of MySQL is not found, enter "vi. bashrc ", enter" Export LD_LIBRARY_PATH = $ LD_LIBRARY_PATH:/usr/local/MySQL/lib "at the end of the line to dynamically Add the path to the environment variable (if it is directly added in the middle of the export, this is a session dialog. The changes to the environment variables are temporary changes. After the session ends, the environment variables will return to the previous state. bashrc is dynamically executed at each compilation, so it can be written at a time and called at a time. bashrc adds environment variables)
Enter gcc-O test $ (./mysql_config -- cflags) test. C $ (./mysql_config-libs)
During compilation, an error message is displayed:
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,
Copy mysql_config to the current path of the program and name it mysql_config. Enter
"CP./workspace/insert/mysql_config./mysql_config"
At this time, "ls" shows that a mysql_config file is copied in the current directory,
Enter gcc-O test $ (./mysql_config -- cflags) test. C $ (./mysql_config -- libs)
In this case, an executable file test is generated under this directory.