Install
Installation
Windows
Option 1: MySQL Installer
Download from mysql.com
Choose Developer Default or Server Only
Configuration:
Port:
3306
Set root password
Enable MySQL as Windows service
Option 2: XAMPP
Download from apachefriends.org
Start MySQL from XAMPP Control Panel
Data Directory:
C:\xampp\mysql\data
Config File:
C:\xampp\mysql\bin\my.ini
Linux
Debian/Ubuntu:
sudo apt update && sudo apt install mysql-server
CentOS/RHEL:
sudo yum install @mysql
macOS
Using Homebrew:
brew install mysql
brew services start mysql
Or:
Download the .dmg installer from MySQL website
Post-Installation
Secure MySQL setup:
sudo mysql_secure_installation
Start/Stop MySQL:
Linux/macOS:
sudo systemctl start mysql
sudo systemctl stop mysql
Windows:
net start mysql
net stop mysql
Or: Use XAMPP Control Panel
Connecting to MySQL
CLI:
mysql -u root -p
Remote Connections
Step 1: Allow external connections
Edit my.cnf
or my.ini
:
bind-address = 0.0.0.0
Step 2: Create remote user:
CREATE USER 'username'@'%' IDENTIFIED BY 'password';
GRANT ALL PRIVILEGES ON *.* TO 'username'@'%';
FLUSH PRIVILEGES;
Port Configuration
Default Port:
3306
To change it:
port = 3307
Config file paths:
Linux/macOS:
/etc/mysql/my.cnf
Windows:
C:\xampp\mysql\bin\my.ini
Last updated