MySQL is one of the most widely used open-source relational database management systems (RDBMS) globally. Developed by Oracle Corporation, it allows for managing, storing, and retrieving data across various applications, from small-scale personal projects to large enterprise-level deployments. MySQL’s popularity stems from its reliability, scalability, and support for multiple platforms. In this article, we’ll discuss the steps on how to download, install and configure MySQL on Ubuntu and on macOS.
MySQL is highly versatile and can be used for a wide range of purposes, including:
The following steps are designed for Ubuntu 22.04, but they should work with other recent versions of Ubuntu.
Step 1: Update Your Package Index
Before installing MySQL, make sure to update your package index to get the latest version available with the following command:
# Sudo apt update
Step 2: Install MySQL Server
To install the MySQL server package, use the following command:
# Sudo apt install mysql-server
This command installs the MySQL server along with its required dependencies. The installation is simple and will automatically start the MySQL service.
Step 3: Secure MySQL Installation
MySQL includes a security script that lets you set a root password, remove anonymous users, block remote root logins, and delete test databases. Run the following command to improve the security of your MySQL setup:
# Sudo mysql_secure_installation
Follow the on-screen prompts to complete the process.
Step 4: Verify MySQL Installation
After installation, check the status of the MySQL service to ensure it is running correctly. Run the following command:
# Sudo systemctl status mysql
You should see that the MySQL service is active and running.
Step 1: Access the MySQL Command-Line
To start using MySQL, you need to log in as the root user. Run the following command:
# Sudo mysql -u root -p
Enter the root password you set during the secure installation process.
Step 2: Create a New MySQL User
For better security, avoid using the root account for daily tasks. Instead, create a new user with the right permission. Use the following commands:
# CREATE USER ‘newuser’@’localhost’ IDENTIFIED BY ‘password;
# GRANT ALL PRIVILEGES ON . TO ‘newuser’@’localhost’ WITH GRANT OPTION;
Step 3: Enable Remote Access to MySQL Server
If you need to access MySQL remotely, edit the MySQL configuration file. Run the following command:
# Sudo nano /etc/mysql/mysql.conf.d/mysqld.cnf
Find the line that says bind-address. Change the IP address to 0.0.0.0 so that MySQL accepts connections from any IP address. Restart MySQL for the changes to take effect. Use the following command:
# sudo systemctl restart mysql
Step 1: Download MySQL
Visit the MySQL official website. Download the macOS version of MySQL.
Step 2: Install MySQL
Once the download is complete, open the .dmg file and follow the installation instructions. The installer will guide you through the process. You can choose choose whether to install MySQL as a startup item (recommended).
Step 3: Start MySQL Server
To start the MySQL server, open System Preferences and click on the MySQL icon. You can start and stop the server from this control panel.
Step 1: Start MySQL via Terminal
You can also start MySQL from the terminal using the following command:
# sudo /usr/local/mysql/support-files/mysql.server start
Step 2: Log in to MySQL
To log in to the MySQL command-line tool, run the following command:
# /usr/local/mysql/bin/mysql -u root -p
Enter the password you set during installation.
Step 3: Set Up MySQL Configuration
For custom configurations, you can edit the MySQL configuration file located at /usr/local/mysql/my.cnf. You can change settings like the default storage engine, buffer sizes, and more
Step 4: Enable Remote Access on macOS
To allow remote access, modify the MySQL configuration file similar to the Ubuntu setup. Edit the bind-address to allow connections from any IP.
Step 5: Starting MySQL at Boot
If you choose not to install MySQL as a startup item during installation, you can enable it manually. Ren the following command:
# sudo cp /usr/local/mysql/support-files/mysql.server /Library/StartupItems/
MySQL is a powerful and reliable database management system suitable for various applications. Whether you are using Ubuntu or macOS, following the steps outlined in this article will help you easily download, install and configure MySQL. By securing your installation and setting up remote access, you can ensure that your database environment is functional and secure.
To maximize the performance and security of your MySQL databases, consider using dedicated ServerHub servers tailored to your specific needs. Whether you are managing a large-scale project or require enhanced reliability and availability, ServerHub’s dedicated servers provide the optimal environment for seamless MySQL operation. These secure and optimized hosting options ensure that your databases perform efficiently and remain protected. Contact us today to discover how ServerHub’s dedicated servers can elevate your MySQL deployment.
Network Monitoring is the process of discovering, mapping, and monitoring a computer network to ensure…
Monitoring network traffic is a crucial component of maintaining a healthy IT infrastructure. Whether you're…
Monitoring network utilization is critical for efficiency, security, and peak performance in today's data-driven environment.…
Overview of Proxmox VE: Open-source Virtualization Management Platform Proxmox Virtual Environment (VE) is an open-source…
Introduction to Oracle Database Oracle Database is a widely adopted relational database management system (RDBMS)…
Deep learning is a type of artificial intelligence that teaches computers to learn from large…
This website uses cookies.