Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- create folder: practice
- create file sample.php: echo'hoi';
- Bash: wget https://files.phpmyadmin.net/phpMyAdmin/4.8.0.1/phpMyAdmin-4.8.0.1-all-languages.zip
- unzip the file: unzip phpMyAdmin-4.8.0.1-all-languages.zip
- Start mysql: sudo service mysqld start
- Login to root user: mysql -u root -p
- create password for root user: update mysql.user set password=password('password') where user = 'root';
- flush privileges;
- restart mysql: sudo service mysqld restart
- create file connection.php and paste this in:
- <?php
- try {
- $dbh = new PDO('mysql:host=localhost;dbname=sample;charset=utf8', 'root', 'password');
- foreach($dbh->query('SELECT * from users') as $row) {
- print_r($row);
- }
- $dbh = null;
- } catch (PDOException $e) {
- print "test: " . $e->getMessage() . "<br/>";
- die();
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement