this is OS specific, (if the user works in MYSQL shell that is) AS A SECURITY RESTRAINT you also may not connect from php with root
/ no password
so run $ sudo mysql_secure_installation
first
EG:
$ sudo mysql_secure_installation
follow the prompts set a root password
then login to mysql as that root user and do this
mysql> GRANT ALL PRIVILEGES ON cki.* TO 'new_user'@'localhost' IDENTIFIED BY 'new_password';
if you are using centos you do
$ sudo yum install php php-mysql mysql-server
$ sudo service httpd restart
if you are using debian you do
$ sudo apt-get install php php-mysql mysql-server
$ sudo service apache2 restart
then you ensure that you have turned off selinux
in /etc/sysconfig/selinux
finally
<?php
$con=mysqli_connect('localhost','new_user','new_password','cki');
if(!$con)
{
echo "not connected";
}else{
echo "connected";
}
?>