I am trying to setup wordpress locally on my Ubuntu 20.04. I have installed all the prerequisites as per tutorial, when i try localhost, it says "Error establishing a database connection".
So, i tried to create database user name and password again with the following details
mysql> CREATE DATABASE lwl;
Query OK, 1 row affected (0.17 sec)
mysql> SHOW DATABASES;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| lwl                |
| mysql              |
| performance_schema |
| sys                |
| wordpress          |
+--------------------+
6 rows in set (0.00 sec)
mysql> CREATE USER 'lwluser'@'localhost' IDENTIFIED BY 'lwl1234';
Query OK, 0 rows affected (0.01 sec)
mysql> GRANT ALL ON lwl.* TO 'lwluser'@'localhost';
Query OK, 0 rows affected (0.00 sec)
mysql> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.01 sec)
mysql> ^DBye
Updated wp-config.php file with the latest values
// ** MySQL settings - You can get this info from your web host ** //
/** The name of the database for WordPress */
define( 'DB_NAME', 'lwl' );
/** MySQL database username */
define( 'DB_USER', 'lwluser' );
/** MySQL database password */
define( 'DB_PASSWORD', 'lwl1234' );
/** MySQL hostname */
define( 'DB_HOST', 'localhost' );
Still i am getting the same error. Then i wrote a simple php file to check
<?php
$link = mysqli_connect('localhost', 'lwluser', 'lwl1234', 'lwl');
if (!$link) {
        die('Could not connect: ' . mysqli_error());
}
echo 'Connected successfully';
mysqli_close($link);
?>                                                                                                               
~   
This failed with 'could not connect' but did not gave any sql error. Can you guys please help me here. I am beginner in web development
Update: sql is running on 3306
$ netstat -tln
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State      
tcp        0      0 127.0.0.1:3306          0.0.0.0:*               LISTEN     
tcp        0      0 127.0.0.53:53           0.0.0.0:*               LISTEN     
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN     
tcp        0      0 127.0.0.1:631           0.0.0.0:*               LISTEN     
tcp6       0      0 :::33060                :::*                    LISTEN     
tcp6       0      0 :::80                   :::*                    LISTEN     
tcp6       0      0 :::1716                 :::*                    LISTEN     
tcp6       0      0 :::22                   :::*                    LISTEN     
tcp6       0      0 ::1:631                 :::*                    LISTEN
I also tried the below and passing the "lwl1234" works
$ mysqlshow -u lwluser -p
Enter password: 
+--------------------+
|     Databases      |
+--------------------+
| information_schema |
| lwl                |
+--------------------+
