App overview screenshotSQL and Database Guides
PostgresMySQLSQLite
Try our free SQL Client
Tools
Connecting to MySQL
Connecting to Drivers
Installing MySQL
Setting up MySQL
MySQL   >   
Installing MySQL   >   
MySQL on Linux

Learn How To Install MySQL on Linux

MySQL is one of the most popular database systems available today. In this guide, we’ll walk you through how to install MySQL on Linux.

Installing MySQL

You can install MySQL by following the commands corresponding to your Linux distribution:

  • Ubuntu

    sudo apt update
    sudo apt install mysql-server
    sudo mysql_secure_installation
    
  • ArchLinux

    sudo pacman -S mariadb
    sudo mysql_install_db --user=mysql --basedir=/usr --datadir=/var/lib/mysql
    sudo systemctl start mysqld
    mysql_secure_installation
    

    Note: the ArchLinux community only provides support for MariaDB, a nearly-identical community fork of MySQL.

  • CentOS/Fedora/RHEL

    First, go to https://dev.mysql.com/downloads/repo/yum/ and find the rpm package name for your desired MySQL version. (e.g. mysql57-community-release-el-9.noarch.rpm). Then, run the following commands:

    wget https://dev.mysql.com/get/mysql57-community-release-el7-9.noarch.rpm
    sudo rpm -ivh mysql57-community-release-el7-9.noarch.rpm
    sudo yum install mysql-server
    sudo systemctl start mysqld
    //grab temporary root password
    sudo grep ‘temporary password’ /var/log/mysqld.log
    sudo mysql_secure_installation
    

During configuration, MySQL will prompt you to set a root password. You will need this later.

You can check to make sure that your MySQL server is now running using one of these commands:

  • Ubuntu

    systemctl status mysql.service
    
  • ArchLinux

    sudo mysql -u root -p version
    
  • CentOS/Fedora/RHEL

    mysqladmin -u root -p version
    

Connect to Your MySQL Database

Now, let’s connect! Open Arctype, press ‘Add New Connection’, and enter your connection information. For now, we’ll use the root user with the password set during installation and the database mysql:

Arctype linux MySQL connection credentials

Press ‘Test Connection’ to confirm that all of your information is correct and then save!

Configure Your MySQL Database

Now that you have connected, you should make a few changes to improve the security of your database. The first is to create a new database that is separate from the mysql informational database you are currently connected to. Click ‘New Query’ and run the following command:

CREATE DATABASE myDB

Next, you should create a new user:

CREATE USER ‘myUser’@’localhost’ IDENTIFIED BY ‘myPassword’

And finally, you’ll need to grant this user full permissions on your database:

GRANT ALL PRIVILEGES ON myDB.* TO ‘myUser’@’localhost’

Run FLUSH PRIVILEGES to apply these permissions.

Go back to the settings menu in your SQL client and switch to this new user and database. You’re all ready to start writing queries!

Get help on databases and SQL. Join our Discord community.