Results 1 to 3 of 3

Thread: Mysql Installation Dramas

  1. #1
    Join Date
    Nov 2010
    Beans
    83

    Mysql Installation Dramas

    Hi all


    I am attempting to install LAMP on Ubuntu 22.04

    Apache/2.4.52
    PHP Version 8.1.2-1ubuntu2.11
    Mysql Ver 8.0.32-0ubuntu0.22.04.2 for Linux on x86_64

    Apache and PHP running. I can log into Mysql from a CLI


    When I try to run Mysql from PHP though it returns:

    Fatal error: Uncaught mysqli_sql_exception: Access denied for user 'root'@'localhost' in /home/nick/Desktop/sites/db_test.php:13 Stack trace: #0 /home/nick/Desktop/sites/db_test.php(13): mysqli_connect() #1 {main} thrown in /home/nick/Desktop/sites/db_test.php on line 13

    Any clues?





    More information:
    .................................................. ..........

    This is the code :

    $servername = "localhost";
    $username = "root";
    $password = "test";
    $dbname = "gm_numbers";


    // Create connection
    $conn = mysqli_connect($servername, $username, $password, $dbname);


    // Check connection
    if (!$conn) {
    die("Connection failed: " . mysqli_connect_error());
    }
    echo "Connected successfully";


    ....


    This is the PHPINFO bit about mysql

    mysqli

    MysqlI Support enabled
    Client API library version mysqlnd 8.1.2-1ubuntu2.11
    Active Persistent Links 0
    Inactive Persistent Links 0
    Active Links 0

  2. #2
    Join Date
    Dec 2023
    Beans
    3

    Re: Mysql Installation Dramas

    I ran into the same permissions issue on a totally different system. But basically the same issue. You have to going into MySql and use commands to change permissions. Look on this page
    https://www.digitalocean.com/community/tutorials/how-to-install-mysql-on-ubuntu-20-04

    The grant privilege command changes those.

  3. #3
    Join Date
    Jun 2014
    Beans
    7,918

    Re: Mysql Installation Dramas

    Did you create a password for the root user in mysql? This is usually done when you run: mysql_secure_installation as well as doing some other basic things.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •