1、修改密码 因为默认是没有密码的为了安全先修改密码,方法是: 先停止mysql /etc/init.d/mysql stop -- 安全模式启动
[root@mysql var]#mysqld_safe --skip-grant-tables &
[1] 10912
[root@mysql var]# 110407 17:39:28 mysqld_safe Logging to "/usr/local/mysql/var//mysql.chinascopefinanical.com.err".
110407 17:39:29 mysqld_safe Starting mysqld daemon with databases from /usr/local/mysql/var/[root@mysql var]# mysql -uroot -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or g.
Your MySQL connection id is 48
Server version: 5.1.41-log Source distributionType "help;" or "h" for help. Type "c" to clear the current input statement.mysql> use mysql;
Database changedmysql> update user set password=password("yourpasswd) where user="root" and host="localhost";
Query OK, 1 row affected (0.00 sec)
Rows matched: 1 Changed: 1 Warnings: 0mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)mysql> quit
Bye
完成上面的操作之后,/etc/init.d/mysqld restart重启mysql
完成上面的操作之后密码就设定好了。
2、安装支持库
root 键入yum search mysql 出现 Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: mirrors.ta139.com
* extras: mirrors.ta139.com
* updates: mirrors.ta139.com
================================ Matched: mysql ================================
mod_auth_mysql.i386 : 使用 MySQL 数据库的 Apache 万维网服务器的基础验证。
qt-MySQL.i386 : 用于 Qt 的 SQL 类别的 MySQL 驱动程序。
MySQL-python.i386 : 一个到 MySQL 的界面
apr-util-mysql.i386 : APR utility library MySQL DBD driver
bytefx-data-mysql.i386 : MySQL database connectivity for Mono
freeradius-mysql.i386 : freeradius 的 MySQL 绑定
freeradius2-mysql.i386 : MySQL support for freeradius
libdbi-dbd-mysql.i386 : libdbi 的 MySQL 插件
mysql.i386 : MySQL client programs and shared libraries
mysql-bench.i386 : MySQL benchmark scripts and data
mysql-connector-odbc.i386 : MySQL 的 ODBC 驱动程序。
mysql-devel.i386 : Files for development of MySQL applicationsmysql-server.i386 : The MySQL server and related files
mysql-test.i386 : The test suite distributed with MySQL
pdns-backend-mysql.i386 : MySQL backend for pdns
perl-DBD-MySQL.i386 : perl 的 MySQL 接口
perl-DBD-Pg.i386 : Perl 的 PostgresSQL 界面
php-mysql.i386 : 一个用于使用 MySQL 数据库的 PHP 程序的模块。
php-pdo.i386 : A database access abstraction module for PHP applications
php-pear-MDB2-Driver-mysql.noarch : MySQL MDB2 driver
php53-mysql.i386 : A module for PHP applications that use MySQL databases
php53-pdo.i386 : A database access abstraction module for PHP applications
qt4-mysql.i386 : MySQL drivers for Qt"s SQL classes
rsyslog.i386 : Enhanced system logging and kernel message trapping daemon
rsyslog-mysql.i386 : MySQL support for rsyslog
unixODBC.i386 : 一个用于 Linux 的完整的 ODBC 驱动程序管理器。红色部分就是我们要的:
yum install mysql-devel-i386 开始安装3、编写程序mysql.c
#include <stdlib.h>
#include <stdio.h>
#include <mysql/mysql.h>
MYSQL *conn_ptr;int main(void){
conn_ptr = mysql_init(NULL);
if (!conn_ptr)
{
fprintf(stderr,"mysql_init failed!
");
return (-1);
}
conn_ptr = mysql_real_connect(conn_ptr,"127.0.0.1","root","","mysql",3306,0,NULL);
if (conn_ptr)
{
printf ("connection succeed!
");
}
else{
printf ("connection failed!
");
return (-2);
}
mysql_close(conn_ptr);
printf ("connection close!
");
return 0;}4、编译程序
gcc -o mydbcon -I /usr/include/mysql/ -L /usr/lib/mysql -lmysqlclient mysql.c5、执行程序
./mydbconconnection succeed!
connection close!重建Control File实现Oracle冷备份迁移到不同实例Oracle内存全面分析之PGA相关资讯 CentOS
- CentOS虚拟机NAT静态IP设置 (07/04/2013 17:09:32)
- CentOS 格式化新硬盘并设置开机自 (07/04/2013 16:50:50)
- 服务器为何用CentOS不用Ubnutu (02/24/2013 15:19:10)
| - CentOS /usr/libexec/gconf-sanity (07/04/2013 17:07:42)
- 为什么我们选择CentOS而不是Debian (06/06/2013 06:19:40)
- 在CentOS下搭建Android 开发环境 (02/18/2013 09:14:14)
|
本文评论 查看全部评论 (0)