How to start MySQL server from command line on Mac OS Lion?
System Design practice on Codemia
Work through 120+ system design problems with detailed solutions, from rate limiters to multi-region storage.
Introduction
Starting MySQL from the command line on Mac OS Lion usually depends on how MySQL was installed. Older package installs use the mysql.server script under /usr/local/mysql, while other setups may use launch agents or Homebrew style service management on newer systems. The safest workflow is to detect installation type, start with the right command, then verify server state.
Identify Your MySQL Installation Layout
Before running start commands, locate the server binaries and support scripts. This avoids calling a wrong path and assuming startup failed.
If support-files/mysql.server exists, you can use the package style startup script. If not, check whether MySQL is managed by another service mechanism.
Also verify whether a server is already running:
If port 3306 is already listening, startup may not be needed.
Start and Stop with mysql.server
For classic installer based deployments, use the bundled management script.
Stop and restart commands:
If command works, you should see a running mysqld process and socket file under the MySQL data directory.
Validate Connection from CLI
After startup, verify both server reachability and authentication.
If this succeeds, your server is active and accepting queries. If login fails, check root credentials and authentication plugin settings for your MySQL version.
For quick health check without entering interactive shell:
Expected output includes mysqld is alive.
Troubleshoot Common Startup Failures
When startup fails, inspect logs first. Typical log locations include /usr/local/mysql/data or paths configured in my.cnf.
Common failure reasons:
- Existing process already bound to port
3306. - Corrupted pid file after abrupt shutdown.
- Permission issues on MySQL data directory.
- Invalid configuration directives in
my.cnf.
If stale pid file blocks startup, remove it only after confirming no active mysqld process is running.
Optional Convenience Alias
If you run these commands frequently, add aliases to your shell profile.
On systems using zsh, place them in ~/.zshrc instead.
Note About Mac OS Lion Age
Mac OS Lion is an old platform with outdated libraries and security posture. If this environment is for legacy compatibility only, keep it isolated and avoid public exposure. For active development, migrate to a supported macOS version or use a containerized database workflow.
Optional Startup Automation
If you need MySQL available after login without manual start commands, you can configure launchd for legacy environments. Use this carefully, and ensure it points to the same MySQL installation path used in manual commands.
Even with automation, keep manual start and stop commands documented for troubleshooting sessions.
Common Pitfalls
- Running Homebrew service commands on a package installation layout.
- Assuming startup succeeded without checking process list or server ping.
- Editing or deleting pid files while another
mysqldinstance is active. - Ignoring error log output and retrying blindly.
- Keeping legacy OS hosts exposed to public networks.
Summary
- Determine MySQL installation type before choosing startup commands.
- Use
mysql.serverunder/usr/local/mysql/support-filesfor classic package installs. - Validate startup with
mysqladmin pingand a test query. - Read error logs first when startup fails.
- Treat Mac OS Lion as legacy and isolate it from modern production workloads.
Related reading
- How to start spring-boot app without depending on Database?
- How to stop insertion of Duplicate documents in a mongodb collection
- How to stop mongo DB in one command
- How to stop mysqld
- How to store arrays in MySQL?
- How to store AWS Cognito User Pool users in DB for instance DynamoDB?
- How to store Emoji Character in MySQL Database
- How to store images using Entity Framework Code First CTP 5?

System Design Fundamentals
Build a strong foundation in designing scalable, reliable distributed systems.
View the courseTrack what you have practised
A free account saves your progress, solutions and study plan across every problem on Codemia.
System Design practice on Codemia
Work through 120+ system design problems with detailed solutions, from rate limiters to multi-region storage.