I try to connect php and mysql several times but I am always getting this errors when I tried to compile php code
this is output on checking php and mysql Command : php -i | grep -i mysql
Configure Command => './configure' '--prefix=/usr' '--sysconfdir=/etc' '--
localstatedir=/var' '--datadir=/usr/share/php' '--mandir=/usr/share/man' '--
enable-fpm' '--with-fpm-user=apache' '--with-fpm-group=apache' '--with-
config-file-path=/etc' '--with-zlib' '--enable-bcmath' '--with-bz2' '--
enable-calendar' '--enable-dba=shared' '--with-gdbm' '--with-gmp' '--enable-
ftp' '--with-gettext' '--enable-mbstring' '--with-mysql=mysqlnd' '--with-
mysqli=mysqlnd' '--with-pdo-mysql=mysqlnd' '--with-readline'
PHP Warning: Unknown: It is not safe to rely on the system's timezone
settings. You are *required* to use the date.timezone setting or the
date_default_timezone_set() function. In case you used any of those methods
and you are still getting this warning, you most likely misspelled the
timezone identifier. We selected the timezone 'UTC' for now, but please set
date.timezone to select your timezone. in Unknown on line 0
mysql
MySQL Support => enabled
Client API version => mysqlnd 5.0.11-dev - 20120503 -
$Id:3c688b6bbc30d36af3ac34fdd4b7b5b787fe5555 $
mysql.allow_local_infile => On => On
mysql.allow_persistent => On => On
mysql.connect_timeout => 60 => 60
mysql.default_host => no value => no value
mysql.default_password => no value => no value
mysql.default_port => no value => no value
mysql.default_socket => no value => no value
mysql.default_user => no value => no value
mysql.max_links => Unlimited => Unlimited
mysql.max_persistent => Unlimited => Unlimited
mysql.trace_mode => Off => Off
mysqli
MysqlI Support => enabled
Client API library version => mysqlnd 5.0.11-dev - 20120503 - $Id:
3c688b6bbc30d36af3ac34fdd4b7b5b787fe5555 $
mysqli.allow_local_infile => On => On
mysqli.allow_persistent => On => On
mysqli.default_host => no value => no value
mysqli.default_port => 3306 => 3306
mysqli.default_pw => no value => no value
mysqli.default_socket => no value => no value
mysqli.default_user => no value => no value
mysqli.max_links => Unlimited => Unlimited
mysqli.max_persistent => Unlimited => Unlimited
mysqli.reconnect => Off => Off
mysqli.rollback_on_cached_plink => Off => Off
mysqlnd
mysqlnd => enabled
Version => mysqlnd 5.0.11-dev - 20120503 - $Id:
3c688b6bbc30d36af3ac34fdd4b7b5b787fe5555 $
Loaded plugins => mysqlnd,debug_trace,auth_plugin_mysql_native_password,auth_plugin_mysql_clear_pa
ssword
API Extensions => pdo_mysql,mysqli,mysql
mysqlnd statistics =>
PDO drivers => mysql, sqlite
pdo_mysql
PDO Driver for MySQL => enabled
Client API version => mysqlnd 5.0.11-dev - 20120503 - $Id:
3c688b6bbc30d36af3ac34fdd4b7b5b787fe5555 $
pdo_mysql.default_socket => /tmp/mysql.sock => /tmp/mysql.sock
This is config in mysql
# Begin /etc/mysql/my.cnf
# The following options will be passed to all MySQL clients
[client]
#password = your_password
#port = 3306
#socket = /run/mysqld/mysqld.sock
#bind-address = 127.0.0.1
# The MySQL server
[mysqld]
user = mysql
port = 3306
pid-file = /srv/mysql/nutnud.pid
socket = /run/mysqld/mysqld.sock
datadir = /srv/mysql
skip-external-locking
key_buffer_size = 16M
max_allowed_packet = 1M
sort_buffer_size = 512K
net_buffer_length = 16K
myisam_sort_buffer_size = 8M
explicit_defaults_for_timestamp=1
#bind-address = 10.0.60.163
bind-address = 0.0.0.0
# Don't listen on a TCP/IP port at all.
#skip-networking
# required unique id between 1 and 2^32 - 1
server-id = 1
# Uncomment the following if you are using BDB tables
#bdb_cache_size = 4M
#bdb_max_lock = 10000
# Uncomment the following if you are using InnoDB tables
#innodb_data_home_dir = /srv/mysql
#innodb_data_file_path = ibdata1:10M:autoextend
#innodb_log_group_home_dir = /srv/mysql
# You can set .._buffer_pool_size up to 50 - 80 %
# of RAM but beware of setting memory usage too high
#innodb_buffer_pool_size = 16M
#innodb_additional_mem_pool_size = 2M
# Set .._log_file_size to 25 % of buffer pool size
#innodb_log_file_size = 5M
#innodb_log_buffer_size = 8M
#innodb_flush_log_at_trx_commit = 1
#innodb_lock_wait_timeout = 50
[mysqldump]
quick
max_allowed_packet = 16M
[mysql]
no-auto-rehash
# Remove the next comment character if you are not familiar with SQL
#safe-updates
[isamchk]
key_buffer = 20M
sort_buffer_size = 20M
read_buffer = 2M
write_buffer = 2M
[myisamchk]
key_buffer_size = 20M
sort_buffer_size = 20M
read_buffer = 2M
write_buffer = 2M
[mysqlhotcopy]
interactive-timeout
This is a code when I use to test php connect to mysql
<?php
$dbhost = 'localhost';
$dbuser = 'root';
$dbpass = '00000000';
$conn = mysqli_connect($dbhost, $dbuser, $dbpass) or die ('Error connecting to mysql');
if ($conn) {
echo "CONNECT OK";
}
$dbname = 'mysql';
mysql_select_db($dbname);
?>
and I get this error
PHP Warning: mysqli_connect(): (HY000/2002): No such file or directory in
/srv/www/php-test.php on line 6
on browser it shows
Error connecting to mysql
which means my php works just fine.
I use Operating system from Linux from scratch book 7.7 and my system doesn't have any packet manager. I can login to mysql on linux. If anybody have any clue which and where I should take a look. Please help me out. Thank you very much.