Installing MySQL on your laptop (optional)

Windows (v10 & 11)

  1. Download MySQL using this link.
  2. Select version 8.0.40 and choose the recommended installer.
  3. Run installer and choose developer default setup. It contains all relevant products and dependencies for MySQL developer purposes. Note: For this course, it is not necessary to install VS Code dependency.
  4. Set up post-installation configuration:
    • Keep TCP port as 3306.
    • Accept and grant Windows Firewall for using the selected port in the previous step.
    • Select legacy authentication in order to retain compabilitiy with other libraries and older versions (IMPORTANT).
    • Enter your own password for root user.
    • Check connections and services.
  5. Verify MySQL service is well-installed:
    • Make sure the mysqld.exe is ticked under the Startup tab when you go to run and type msconfig.
    • Same goes for Services, look for the MySQL services there, right click > properties and make sure the startup types are selected as automatic.

MacOS

  1. Download MySQL using this link.
  2. Select version 8.0.40 and your architecture (x86 64 bit or ARM 64 bit).
  3. The initial wizard introduction screen references the MySQL server version to install. Click Continue to begin the installation. The MySQL community edition shows a copy of the relevant GNU General Public License. Click Continue and then Agree to continue.
  4. Set up post-installation configuration:

    • From the Installation Type page you can either click Install to execute the installation wizard using all defaults, click Customize to alter which components to install (MySQL server, MySQL Test, Preference Pane, Launchd Support – all but MySQL Test are enabled by default). Note: For this course, default settings works.
    • After a successful new MySQL Server installation, complete the configuration steps by choosing legacty authentication type for passwords in ordert to retain compability with other libraries and older versions (IMPORTANT)

    • Define the root password.
    • Enable (or disable) MySQL server at startup.
  5. Verify MySQL service is correctly installed:
    • Open macOS system preferences and select the MySQL preference panel, and then execute Start MySQL Server.
    • To configure MySQL to automatically start at bootup, you can:
    $ sudo launchctl load -w com.oracle.oss.mysql.mysqld.plist
    

Linux (Ubuntu)

  1. Add MySQL APT repository.

     $ wget https://dev.mysql.com/get/mysql-apt-config_0.8.23-1_all.deb
    
    $ sudo dpkg -i mysql-apt-config_0.8.23-1_all.deb
    

    Select your Ubuntu distro and next prompt shows MySQL 8.0 chosen by default. Choose the first option and click OK.

    Update MySQL Repository.

    $ sudo apt update
    
  2. Install MySQL 8.0 on Ubuntu22.04/20.04

    • Ubuntu 22.04:
    $ sudo apt update
    
    • Ubuntu 20.04:
    $ sudo apt install mysql-client mysql-community-server mysql-server
    

    Note: Set default authentication plugin. Use Strong Password Encryption mechanism.

  3. Creating MySQL Database and User (Optional)

    While still connected to MySQL, you can run the following commands to create a database and grant user the permissions.

     CREATE DATABASE mydatabase;
     CREATE USER 'mydbuser'@'%' IDENTIFIED BY 'DBUserStr0ngPassw0d.';
      GRANT ALL PRIVILEGES ON mydatabase.* TO 'mydbuser'@'%';
      FLUSH PRIVILEGES;
     exit
    

    Enabling MySQL remote access (Optional)

     sudo vim /etc/mysql/mysql.conf.d/mysqld.cnf
    

    Look for the line ‘bind_address’ and change as below:

     #By default we only accept connections from localhost
     #bind-address   = 127.0.0.1
     bind-address   = 0.0.0.0
    

    Save the file and restart mysql

    $ sudo systemctl restart mysql
    

    Allow remote connections through the firewall

    $ sudo ufw allow from <remote_IP_address> to any port 3306
    $ sudo ufw enable
    

    To access the database from a remote machine, run the following command:

     $ mysql -u user -h database_server_ip -p