[MySQL]MySQL 설치, 삭제, 서버 관련 명령어

Aiden·2022년 5월 6일
1
post-thumbnail

on MAC

Install

$ brew update
$ brew search mysql
$ brew install mysql

Start Server

# MySQL 서버 실행
$ mysql.server start

# MySQL 서버 데몬으로 실행
$ brew services start mysql

Set Password

$ mysql_secure_installation

Access MySQL Server

$ mysql -u root -p

Exit MySQL Server

mysql> exit

Stop Server

# MySQL 서버 중단
$ mysql.server stop

# MySQL 데몬 서버 중단
$ brew services stop mysql

Restart Server

# MySQL 서버 재실행
$ mysql.server restart

# MySQL 서버 데몬으로 재실행
$ brew services restart mysql

Uninstall

$ brew uninstall mysql
$ rm -rf /usr/local/var/mysql
$ rm /usr/local/etc/my.cnf


on Ubuntu

Install

$ sudo apt-get update
$ sudo apt-get install mysql-server -y

Start Server

# method 1
$ sudo service mysqld start

# method 2
$ sudo /etc/init.d/mysqld start

# method 3
$ sudo systemctl start mysqld

Set Password

$ sudo mysql_secure_installation

Access MySQL Server

$ sudo mysql -u root -p

Exit MySQL Server

$ mysql> exit

Stop Server

# method 1
$ sudo service mysqld stop

# method 2
$ sudo /etc/init.d/mysqld stop

# method 3
$ sudo systemctl stop mysqld

Restart Server

# method 1
$ sudo service mysqld restart

# method 2
$ sudo /etc/init.d/mysqld restart

# method 3
$ sudo systemctl restart mysqld

Uninstall

$ sudo apt-get purge mysql-server mysql-common mysql-client -y
$ sudo rm -rf /etc/mysql /var/lib/mysql /var/log/mysql
$ sudo rm -rf /var/log/mysql.*
$ sudo apt-get autoremove
$ sudo apt-get autoclean

0개의 댓글