0

is it possible?

I want to embed MySQL in my project.

$path = str_replace('www','',getcwd());
system('"'.$path.'mysql\bin\mysqld.exe');

$mysqli = new mysqli("localhost","root","","mix_pos");

// Create connection
if ($mysqli->connect_errno) {
   echo "Failed to connect to MySQL: " . $mysqli->connect_error;
  exit();
 }

  echo "Connected successfully";
deefour
  • 34,974
  • 7
  • 97
  • 90
Hasan
  • 1
  • 2
  • Are you using core php or laravel? – Tayyab mehar Apr 21 '21 at 17:50
  • Have you tried using SQLite instead? That's built to be portable. – M. Eriksson Apr 21 '21 at 17:51
  • I using laravel, but I try PHP, – Hasan Apr 21 '21 at 17:55
  • I develop my project using MySQL – Hasan Apr 21 '21 at 17:56
  • @Tayyabmehar how can use mysql – Hasan Apr 21 '21 at 17:58
  • Laravel has support for SQLite so if you use their database classes (query builder/eloquent) instead of using your own mysql connection using mysqli, it should work the same. Trying to bundle some stand-alone version of mysql will most likely be way more complicated, if even possible in this case. – M. Eriksson Apr 21 '21 at 18:35
  • Does this answer your question? [How to fetch from MySql Database when using Include connection?](https://stackoverflow.com/questions/43533726/how-to-fetch-from-mysql-database-when-using-include-connection) – nbk Apr 21 '21 at 20:21

1 Answers1

0

If you are using laravel project than simply you have to configure your mySql database in .env file

DB_CONNECTION=mysql
DB_HOST=190.0.0.1
DB_PORT=4008
DB_DATABASE=testProject
DB_USERNAME=root
DB_PASSWORD=

And you can also review config.php file.

Tayyab mehar
  • 648
  • 6
  • 8