top of page
  • Linkedin
  • bluesky
  • Instagram

MySQL on Ubuntu Server

  • solbergtonje
  • 16 nov. 2024
  • 2 min läsning

Uppdaterat: 25 dec. 2024

Structured Query Language (SQL) is used for communicating with databases, and MySQL is a popular database management system (DBMS), read more here, as well as a part of the LAMP-stack.


ree


Let's start by updating the package manager cache, run the command "sudo apt update"


ree



Then install MySQL with the command "sudo apt install mysql-server"Write "y" to continue


ree



MySQL is now installed on the Ubuntu Server, the next step is optional but recommended.


MySQL comes with a pre-installed security script, run this with the command "sudo mysql_secure_installation" Whether or not you choose to enable "validate password component", one should always use strong and unique passwords.


ree



There will be questions about anonymous users, test database, and remote logins, it can be wise to answer "y" to remove and disable these.


ree



Then answer "y" to reload for the changes to take effect immediately in MySQL


ree




If you encounter this problem:

ree

Resolve it by switching to another tty, for example with "CTRL + ALT + F2"

ree


Run the command "sudo killall -9 mysql_secure_installation" in the other tty, in this example tty2. Then see how it has terminated the mysql secure installation in the original tty

ree


Then start MySQL with the command "sudo mysql" and run this SQL query: "ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'insert password here' ; "and then type "exit" to leave MySQL

ree

Now run the mysql security script again with the command "sudo mysql_secure_installation"



To enter MySQL as the root user, run the command "mysql -u root -p"


ree



To leave MySQL, run the command "exit"


ree


Learn more about SQL and queries here



SOURCES


Contact / Kontaktformulär

© 2024-2025 Tonje Solberg

bottom of page